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

随机推荐

  1. qpython 读入数据问题: EOF error with in
  2. 使用python 3.6将多个文件并行加载到内存
  3. Python学习札记(二十六) 函数式编程7 修
  4. Python自然语言处理实践: 在NLTK中使用斯
  5. Python基本数据结构
  6. caffe python批量抽取图像特征
  7. 【原创】Python处理海量数据的实战研究
  8. 从正则表达式中浏览和提取字符类
  9. Python自学,Day3-Python基础
  10. 报错 src/png_io.c:3:17: error: png.h: