最近项目中需要用jquery判断input里checkbox是否被选中,发现用attr()获取不到复选框改变后的状态,最后查资料发现jQuery 1.6以后新增加了prop()方法,借用官方的一段描述就是: The difference between attributes and properties can be important in specific situations. Before jQuery 1.6, the .attr() method sometimes took pro
var checked = document.getElementsByName("checked_c[]"); var checked_counts = 0; for(var i = 0; i < checked.length; i ++){ if(checked[i].checked){ checked_counts++; } } checked_counts 即是统计复选框选中个数