<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<style type="test/css">
#table{
color:green;
margin:0 auto;
300px;
height:200px;
font-weight:400px;
font-size:large;
text-align:center;}
.select{
background:rgba(50,50,50,0.5);
}
</style>
<script src></script>
</head>
<body>
<table id="table" border="1px solid blue" cellspacing='0' cellpadding='0'>
<thead>
<tr><th class="header"><input id="checkall" type="checkbox"name="checkall"/></th><th class=‘header‘>header</th><th class='header‘>header</th><th class='header‘>header</th>
</thead>
<tbody>
<tr><td><input class='checklist' type='checkbox' name='checklist'/></td><td>data</td><td>data</td><td>data</td>
<tr><td><input class='checklist' type='checkbox' name='checklist'/></td><td>data</td><td>data</td><td>data</td>
<tr><td><input class='checklist' type='checkbox' name='checklist'/></td><td>data</td><td>data</td><td>data</td>
</tbody>
</table>
<script>
$('body').on('click',table thead tr input[name="checkall"]',function(){
if(this.checked){
$('tbody input[name="checklist"]').prop('checked',$(this).prop('checked'));
$('tbody tr').addClass('select');
}else{
$('tbody input[name="checklist"]').prop('checked',false);
$('tbody tr').addClass('select');
}
});
$('body').on('click','table tbody tr',function(){
$(this).toggleClass('select');
$(this).find('input[name='"checklist"]').prop('checked',$(this).hasClass('select');
$('#checkall').prop('checked',$('.checklist').length==$('.checklist').filter(":checked").length);
});
</script>
</body>
</html>