Javascript Jquery - 如何分解数组值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10348213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 00:59:22 来源:igfitidea点击:
Jquery - how to explode arrays value
提问by snnlankrdsm
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 "-" ?
value 是 array 的值。可以用“-”爆破值吗?
回答by Bibin Velayudhan
You can use split
您可以使用 split
var arr = str.split('-');
回答by Dunhamzzz
Yes, you use value.split('-');
是的,你用 value.split('-');
回答by Endang Taryana
you can write like this
你可以这样写
function add_nik(id)
{
$('#modal_form').modal('hide'); // show bootstrap modal
var hasil=id.split(',');
$('#nik').val(hasil[0]);
$('#nama').val(hasil[1]);
}
in yout html code
在你的 html 代码中
<input type="text" name="nama" id="nama" >
<input type="text" name="nik" id="nik>