1、$.each()
$.each(object,function(index,e){ ... }); object --> 需要遍历的对象或数组 index --> 索引 e --> 循环的每个元素
示例一:
let temp = "";
$.each(selected, function (index, obj) { if (index != selected.length - 1) { temp = temp + obj.id+ ","; } else { temp = temp + obj.id; } })
示例二:
let t = "";
selected.each(function (index, obj) { if (index, obj) { t = t + obj.id + ","; } else { t = t + obj.id; } })