<script type="text/javascript">
$(function(){
//checkboxAll全选事件
$("#checkboxAll").bind("click",function(){
$("[name=checkbox]:checkbox").attr("checked",this.checked);
});
//checkbox事件
$("[name=checkbox]:checkbox").bind("click",function(){
var $chk = $("[name = checkbox]:checkbox");
$("#checkboxAll").attr("checked", $chk.length == $chk.filter(":checked").length);
});
});
//点击该行,checkbox自动选中
$("tr").click(function (e) {
if ($(e.target).attr("type") != "checkbox") {
$(this).find(":checkbox").attr("checked", !$(this).find(":checkbox").attr("checked"));
}
});
</script >
转载于:https://my.oschina.net/moziqi/blog/307059