jQuery(function($) {
var texts = []
$('.list li :checkbox').change(function() {
texts = []
$(".list li :checkbox:checked").each(function (i, eleDom) {
texts.push($(this).closest("li").text())
})
$('p').text(texts)
})
$('.tj').click(function() {
$('.yx').html("<input type='checkbox' value='' />" + texts + "")
})
})
</script>
分割后组装成{x:y}可以使用下面的方法:var strTem="x=y"strTem="{"+strTem.split("=").join(":")+"}"
split方法首先把字符串按照给定的标识字符分割为数组{"x","y"},数组的join函数按照给定的字符串把数组中的元素拼接为字符串。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)