Can anyone help with the following, it doesn't return any checked checkboxes.. Am i doing somethign wrong?
任何人都可以帮助以下,它不会返回任何选中的复选框..我做错了吗?
I have
$("input[type=checkbox][checked] .type-element").each(
function(index) {
alert('checked' + index);
}
);
here is part of my html ( i have a number of them all as type-container)
这是我的html的一部分(我有很多都作为类型容器)
<div id="type-1" class="type-container">
<div class="type-description">
test
</div>
<input id="11" class="type-element" type="checkbox"/>
</div>
1 个解决方案
#1
Just do:
$(":checked")...
for checked checkboxes. Also you have an extraneous space in your expression before ".type-element". If you want to make sure the checked checkboxes have that class use:
选中复选框。此外,在“.type-element”之前,表达式中还有一个无关的空间。如果要确保选中该复选框,请使用该类:
$(":checked.type-element")...
not ":checked .type-element"
(note the space).
不是“:checked .type-element”(注意空格)。
So the end result is:
所以最终的结果是:
$(":checked.type-element").each(
function(index) {
alert('checked' + index);
}
);
#1
Just do:
$(":checked")...
for checked checkboxes. Also you have an extraneous space in your expression before ".type-element". If you want to make sure the checked checkboxes have that class use:
选中复选框。此外,在“.type-element”之前,表达式中还有一个无关的空间。如果要确保选中该复选框,请使用该类:
$(":checked.type-element")...
not ":checked .type-element"
(note the space).
不是“:checked .type-element”(注意空格)。
So the end result is:
所以最终的结果是:
$(":checked.type-element").each(
function(index) {
alert('checked' + index);
}
);