jQuery .each()索引? [英] jQuery .each() index?
本文介绍了jQuery .each()索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用
$('#list option').each(function(){
//do stuff
});
循环遍历列表中的选项。
我想知道如何获得当前循环的索引?
to loop over the options in a list. I am wondering how I could get the index of the current loop?
因为我不想让var i = 0;
和循环内部有i ++;
as I dont want to have to have var i = 0; and inside the loop have i++;
推荐答案
$('#list option').each(function(index){
//do stuff
alert(index);
});
提醒索引:)
这篇关于jQuery .each()索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文