当前位置:网站首页>使用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;
})
})

边栏推荐
- window11 conda安装pytorch过程中遇到的一些问题
- Pytorch extract skeleton (differentiable)
- Specify the format time, and fill in zero before the month and days
- Openwrt build Hello ipk
- (POJ - 3685) matrix (two sets and two parts)
- Auto. Getting started with JS
- 生成随机密码/验证码
- 1005. Maximized array sum after K negations
- Interval sum ----- discretization
- Interesting drink
猜你喜欢
随机推荐
1323. Maximum number of 6 and 9
Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
Advancedinstaller安装包自定义操作打开文件
Problem - 1646C. Factorials and Powers of Two - Codeforces
AcWing——第55场周赛
Click QT button to switch qlineedit focus (including code)
Pyside6 signal, slot
window11 conda安装pytorch过程中遇到的一些问题
Codeforces round 797 (Div. 3) no f
Generate random password / verification code
1013. Divide the array into three parts equal to and
Codeforces Round #803 (Div. 2)A~C
Auto. Getting started with JS
本地可视化工具连接阿里云centOS服务器的redis
Some problems encountered in installing pytorch in windows11 CONDA
Discussion on QWidget code setting style sheet
Flask框架配置loguru日志库
Openwrt source code generation image
969. Pancake sorting
input 只能输入数字,限定输入








