当前位置:网站首页>使用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;
})
})
边栏推荐
- QT实现窗口置顶、置顶状态切换、多窗口置顶优先关系
- 第 300 场周赛 - 力扣(LeetCode)
- 1005. Maximized array sum after K negations
- Codeforces Round #800 (Div. 2)AC
- Sword finger offer II 019 Delete at most one character to get a palindrome
- Opencv learning log 27 -- chip positioning
- Acwing - game 55 of the week
- window11 conda安装pytorch过程中遇到的一些问题
- Codeforces - 1526C1&&C2 - Potions
- Flag framework configures loguru logstore
猜你喜欢
C language learning notes
Penetration test (4) -- detailed explanation of meterpreter command
pytorch提取骨架(可微)
Codeforces Round #802(Div. 2)A~D
Programmers, what are your skills in code writing?
树莓派4B安装opencv3.4.0
QT realizes window topping, topping state switching, and multi window topping priority relationship
Install Jupiter notebook under Anaconda
VMware Tools和open-vm-tools的安装与使用:解决虚拟机不全屏和无法传输文件的问题
浏览器打印边距,默认/无边距,占满1页A4
随机推荐
1605. Sum the feasible matrix for a given row and column
Is the sanic asynchronous framework really so strong? Find truth in practice
807. Maintain the urban skyline
Discussion on QWidget code setting style sheet
Openwrt build Hello ipk
B - Code Party (girls' competition)
628. Maximum product of three numbers
C basic grammar
栈的经典应用—括号匹配问题
去掉input聚焦时的边框
AcWing:第58场周赛
Codeforces Round #801 (Div. 2)A~C
605. Planting flowers
Bidirectional linked list - all operations
QT realizes window topping, topping state switching, and multi window topping priority relationship
Date plus 1 day
Installation and configuration of MariaDB
1013. Divide the array into three parts equal to and
Browser print margin, default / borderless, full 1 page A4
Find 3-friendly Integers