当前位置:网站首页>使用jq实现全选 反选 和全不选-冯浩的博客
使用jq实现全选 反选 和全不选-冯浩的博客
2022-07-06 09:29:00 【冯浩(grow up)】
思路:
首先调用jq文件
当点击全选的时候我们让他全部为true
当点击全不选的时候我们让他全部为false
当点击反选的时候 使用echo循环遍历checked 使用 !取反;
html部分
<input type="checkbox">
<input type="checkbox">
<button >全选</button>
<button >不全选</button>
<button'>反选</button>
js部分
// 点击全选
$('button:first').click(function(){
$(':checkbox').prop('checked',true);
})
// 点击全不选 eq:获取反选按钮
$('button:eq(1)').click(function(){
$(':checkbox').prop('checked',false);
})
// 点击反选
$('button:last').click(function(){
$(':checkbox').each(function(index,item){
item.checked = !item.checked;
})
})
边栏推荐
- VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
- Codeforces Round #801 (Div. 2)A~C
- Problem - 1646C. Factorials and Powers of Two - Codeforces
- 875. 爱吃香蕉的珂珂 - 力扣(LeetCode)
- Codeforces Round #800 (Div. 2)AC
- HDU - 6024 building shops (girls' competition)
- F - birthday cake (Shandong race)
- Penetration test (4) -- detailed explanation of meterpreter command
- 分享一个在树莓派运行dash应用的实例。
- Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
猜你喜欢
Programmers, what are your skills in code writing?
1903. Maximum odd number in string
Codeforces Round #801 (Div. 2)A~C
Click QT button to switch qlineedit focus (including code)
Kubernetes集群部署
读取和保存zarr文件
1323. Maximum number of 6 and 9
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
Li Kou - 298th weekly match
Problem - 922D、Robot Vacuum Cleaner - Codeforces
随机推荐
MariaDB的安装与配置
2027. Minimum number of operations to convert strings
Kubernetes cluster deployment
顺丰科技智慧物流校园技术挑战赛(无t4)
Acwing - game 55 of the week
Input can only input numbers, limited input
Borg maze (bfs+ minimum spanning tree) (problem solving report)
栈的经典应用—括号匹配问题
Suffix expression (greed + thinking)
Data storage in memory & loading into memory to make the program run
Interval sum ----- discretization
1005. Maximized array sum after K negations
(POJ - 3579) median (two points)
Hdu-6025-prime sequence (girls' competition)
pytorch提取骨架(可微)
Codeforces Round #799 (Div. 4)A~H
(POJ - 3258) River hopper (two points)
Sanic异步框架真的这么强吗?实践中找真理
HDU - 6024 building shops (girls' competition)
Acwing: the 56th weekly match