9

Is it possible to explode datas in array according to a charachter?

.each(myArr, function(key, value) { 

});

i take array like that

value is the values of array . Can explode value with "-" ?

4

4 回答 4

26

Use split():

var items = value.split('-');
于 2012-04-27T09:33:47.677 回答
8

您可以使用split

 var arr = str.split('-');
于 2012-04-27T09:34:48.070 回答
4

是的,你使用value.split('-');

于 2012-04-27T09:34:09.993 回答
1

你可以这样写

function add_nik(id)
{
    $('#modal_form').modal('hide'); // show bootstrap modal
    var hasil=id.split(',');
    $('#nik').val(hasil[0]);
    $('#nama').val(hasil[1]);
}

在你的 html 代码中

<input type="text" name="nama" id="nama" >
<input type="text" name="nik" id="nik>
于 2017-05-01T15:22:15.653 回答