jQuery菜单实例(全选,反选,取消)
2017-08-28 08:08
603 查看
废话不多说,直接上代码
<!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菜单实例(全选,反选,取消)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- jquery实现全选,取消,反选的功能&实现左侧菜单
- 如何利用jquery实现一句话全选/取消全选的实例代码
- ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
- ASP.NET jQuery 实例6 (实现CheckBoxList成员全选或全取消)
- 全选与取消【jQuery实例】
- checkbox全选/取消全选以及checkbox遍历jQuery实现代码
- jquery checkbox 全选 取消 demo
- jquery实现checkbox全选全不选的简单实例
- jquery实现checkbox全选,反选,取消选择
- Jquery-全选和取消的一个坑
- jQuery实例——展示表格点击变色、全选、删除
- jQuery实现多选框全选/取消
- jquery实现radio按纽全不选和checkbox全选的实例
- Jquery:checkbox全选和全取消
- jQuery--checkbox全选/取消全选
- jQuery--checkbox全选/取消全选
- jquery实现checkbox全选,反选,取消选择
- jquery实现checkbox全选,反选,取消选择
- jquery全选,取消全选