关于jquery菜单全选,反选,取消功能很普遍,本文小编就为大家带来一篇jquery菜单实例(全选,反选,取消)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧,希望能帮助到大家。
废话不多说,直接上代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="button" value="全选" onclick="checkAll()">
<input type="button" value="反选" onclick="reverseAll()">
<input type="button" value="取消" onclick="cancleAll()">
<table border="1">
<thead>
<tr>
<th>选择</th>
<th>IP</th>
<th>端口</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox"></td>
<td>1.1.1.1</td>
<td>80</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>1.1.1.1</td>
<td>80</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>1.1.1.1</td>
<td>80</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>1.1.1.1</td>
<td>80</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>1.1.1.1</td>
<td>80</td>
</tr>
</tbody>
</table>
<script type="text/javascript" src='jquery-3.2.1.js'></script>
<script type="text/javascript">
function checkAll(){
$(':checkbox').prop('checked',true);
}
function cancleAll() {
$(':checkbox').prop('checked',false);
}
function reverseAll(){
$(':checkbox').each(function(){
var v = $(this).prop('checked')? false:true; /*三元运算: var v = 条件? 真值:假值*/
$(this).prop('checked',v)
})
}
</script>
</body>
</html>相关推荐:
使用jquery菜单插件HoverTree仿京东无限级菜单_jquery
以上就是jQuery菜单全选,反选,取消实例解析的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号