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

Jquery怎么获得复选框被选中的个数?
想要得到被选中的数量
用循环可以做,需要挨个去判断是否checked
jquery有没有更简单的方法?
------解决方案--------------------

<script src="js/jquery-1.3.2.js"></script>
<script>
function doit(){
alert($("input[name='ChooseOne']:checked").length);
}

</script>

<input type="checkbox" name="ChooseOne" >
<input type="checkbox" name="ChooseOne" >
<input type="checkbox" name="ChooseOne" >
<input type="checkbox" name="ChooseOne" >
<input type="checkbox" name="ChooseOne" >

<input type="button" value="get" onclick="doit()">


------解决方案--------------------
简单的还是用js来实现吧

接分咯