jquery select(每个)所有选中的复选框?
16lz
2021-01-22
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);
}
);
更多相关文章
- 具有不间断空格的呈现字符串
- CSS文件:SyntaxError:期望表达式,得到'。
- 如何在SQL中写正则表达式(适用于Ms SQL Server 2000以上版本)
- 用正则表达式剔除文本里面HTML标记
- 值得收藏的正则表达式(匹配中文字符、匹配双字节字符、匹配HTML标
- js去掉html标签和去掉字符串文本的所有的空格
- java+空格怎么表示,我想实现一段Java字符在html中20个连续空格
- 关于使用js/jquery监听input框输入的银行卡号,在输入时放大显示且
- PHP正则表达式