日期:2014-05-16  浏览次数:20287 次

请问下 动态生成的checkbox选中的时候,怎么有值是undefined?
请问下 动态生成的checkbox选中的时候,怎么有值是undefined?

我的checkbox是动态生成的,

查找的时候用的 $("div[id="queryList"]").find(input type="checkbox" checked)




<div >

<input type="checkbox" id="firstCheckBox"/>//全选的checkbox
//
下面是循环的 
<input type="checkbox" id="checkbox0"/><input type="hidden" id="name0" value="name0"/>
</div>

$("input[type=checkbox]:checked").each(function(){ 
     
});  


这种方式。

如果生成的有5个checkbox,我只要全选,提交的值 第一个就是为undefined
如果只有四个,三个,两个,一个,则能正常输出值。请问这是为什么呢?谢谢。

------解决方案--------------------
好好再学学jQuery
------解决方案--------------------
序号没搞对。没代码,不知道。
------解决方案--------------------
没错,如果你真要讨论就应该放出全部相关代码。
------解决方案--------------------
$("input[type=checkbox]:checked")

这东西会包含你全选的那个复选框吧
<input type="checkbox" id="firstCheckBox"/>//全选的checkbox

value值没有吧?
------解决方案--------------------
引用:
Quote: 引用:

$("input[type=checkbox]:checked")

这东西会包含你全选的那个复选框吧
<input type="checkbox" id="firstCheckBox"/>//全选的checkbox

value值没有吧?


恩 估计是包含了这个的值,请问怎么判断不包含这个呢 谢谢·。


通常用 name属性不直接用type=checkbox