<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type=" text/javascript">
$(function(){
$("#d1").click(function(){
$(".t1").prop("checked",true);
})
$("#d2").click(function(){
$(".t1").prop("checked",false);
})
$("#d3").click(function(){
$(".t1").each(function(){
$(this).prop("checked",!$(this).prop("checked"));
})
})
})
</script>
</head>
<body>
<table border="1px">
<tr>
<td>
<input type="checkbox" id="d1">全选
<input type="checkbox" id="d2">全不选
<input type="checkbox" id="d3">反选
</td>
<td>姓名</td>
</tr>
<tr>
<td><input type="checkbox" class="t1"></td>
<td>张三</td>
</tr>
<tr>
<td><input type="checkbox" class="t1"></td>
<td>张三</td>
</tr>
<tr>
<td><input type="checkbox" class="t1"></td>
<td>张三</td>
</tr>
<tr>
<td><input type="checkbox" class="t1"></td>
<td>张三</td>
</tr>
</table>
</body>
</html>
jQuery全选和反选
最新推荐文章于 2024-01-23 19:19:19 发布