<table id="table"> <thead> <tr> <td><input type="checkbox" id="thtd" name="thtd"/></td> </tr> </thead> <tbody> <tr> <td><input type="checkbox" id="tbtd" name="tbtd"/></td> </tr> <tr> <td><input type="checkbox" id="tbtd" name="tbtd"/></td> </tr> <tr> <td><input type="checkbox" id="tbtd" name="tbtd"/></td> </tr> </tbody> </table>
js代码
$(document).ready(function(){
$("#thtd").bind("click",function(){
alert($(this).prop("checked"));
var flag = $(this).prop("checked");
if(flag){
$("#table #tbtd").prop("checked",true);
}else{
$("#table #tbtd").prop("checked",false);
}
})
});
实现checkbox全选和全不选的功能,布布扣,bubuko.com
原文地址:http://my.oschina.net/u/1026723/blog/294860