Jquery 如何获取复选框列表的索引
我需要循环查看复选框列表。我在网上搜索了一下,找到了一些代码。但是我仍然有一个问题,Jquery 如何获取复选框列表的索引,jquery,Jquery,我需要循环查看复选框列表。我在网上搜索了一下,找到了一些代码。但是我仍然有一个问题,警报只显示第一次,索引是0。我引用了这个 呈现为。因此,您不是在项目中循环,而是在(单个)中循环 function setcheckbox() { $('.chkClass input[type=checkbox]').each(function (i, obj) { alert(i); if (i == 2) { this.prop('checked', true); }
警报只显示第一次,索引是0
。我引用了这个
呈现为
。因此,您不是在项目中循环,而是在(单个)
中循环
function setcheckbox() {
$('.chkClass input[type=checkbox]').each(function (i, obj) {
alert(i);
if (i == 2) {
this.prop('checked', true);
}
});
}
尝试将input[type=checkbox]
添加到选择器中,指定要在
中查找复选框
function setcheckbox() {
$('.chkClass input[type=checkbox]').each(function (i, obj) {
alert(i);
if (i == 2) {
this.prop('checked', true);
}
});
}
呈现为
。因此,您不是在项目中循环,而是在(单个)
中循环
function setcheckbox() {
$('.chkClass input[type=checkbox]').each(function (i, obj) {
alert(i);
if (i == 2) {
this.prop('checked', true);
}
});
}
尝试将input[type=checkbox]
添加到选择器中,指定要在
中查找复选框
function setcheckbox() {
$('.chkClass input[type=checkbox]').each(function (i, obj) {
alert(i);
if (i == 2) {
this.prop('checked', true);
}
});
}