<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="/jquery.mini.js"></script>
</head>
<style>
*{
margin: 0;
padding: 0;
}
table{
width: 420px;
height: 300px;
}
thead{
background-color: rgb(0,141,208);
color: #fff;
}
.bg{
background-color: rgb(247,250,247);
}
tbody tr{
background-color: rgb(238,241,238);
color: rgb(84,85,105);
}
</style>
<body>
<table>
<thead id='j_cbAll'>
<tr>
<th><input type="checkbox" class="checkall"></th>
<th>商品</th>
<th>价钱</th>
</tr>
</thead>
<tbody id='j_tbs'>
<tr>
<td><input type="checkbox" class="check"></td>
<td>iPone8</td>
<td>8000</td>
</tr>
<tr>
<td><input type="checkbox" class="check"></td>
<td>iPad Pro</td>
<td>5000</td>
</tr>
<tr>
<td><input type="checkbox" class="check"></td>
<td>iPad Air</td>
<td>2000</td>
</tr>
<tr>
<td><input type="checkbox" class="check"></td>
<td>Apple Watch</td>
<td>2000</td>
</tr>
</tbody>
</table>
<script>
$(function(){
$(".checkall").change(function(){
$(".check").prop("checked",$(".checkall").prop("checked"))
})
$(".check").change(function(){
if($(".check:checked").length===$(".check").length){
$(".checkall").prop("checked",true)
}else{
$(".checkall").prop("checked",false)
}
})
})
</script>
</body>
</html>
接上一篇文章
Guess you like
Origin blog.csdn.net/weiyuyang250/article/details/120793566
Recommended
Ranking