JQuery 数组遍历方法
发布于 6 年前 作者 zWorker9902 2435 次浏览 来自 问答

JQuery 数组遍历方法

方法一

// 遍历选项
$domSource.find(“li”).each(function(index, element){ var sourceObj = aryVodeoSource[index]; if (sourceObj != undefined){ $(this).attr(“value”, sourceObj.index); $(this).text(sourceObj.alias); } else{ $(this).remove(); } }); 1 2 3 4 5 6 7 8 9 10 11 12 方法二

// 遍历数组 for(var i=$domSource.find(“li”).length; i<aryVodeoSource.length; i++){ $domSource.find(“ul”)[0].appendChild(createSingleBoxLi(aryVodeoSource[i].index, aryVodeoSource[i].alias)); } 1 2 3 4 方法三

// 遍历数组 $.each(aryVodeoSource,function(index,value){ if(value.index == videoSourceIndex){ $domSource.webumcSelect(“value”, value.alias); } });

回到顶部