当前位置:网站首页>第3章业务功能开发(实现全选按钮实时的响应)
第3章业务功能开发(实现全选按钮实时的响应)
2022-07-25 08:04:00 【做一道光】
客户需求:
当点击全选框时,实现全选框勾选,以及所有数据的复选框也进行勾选。
再次点击全选框时,实现全选框勾选取消,以及所有数据的复选框也进行勾选取消。
点击全选框后,当点击数据项的复选框取消当前数据项的勾选,全选框也应取消勾选
功能开发:
在index.jsp页面的js中进行编写
//给全选按钮设置全选功能
$("#checkAll").click(function () {
$("#tBody input[type='checkbox']").prop("checked",this.checked);
});
//给数据项的多选框添加单击事件
$("#tBody").on("click","input[type='checkbox']",function () {
if ($("#tBody input[type='checkbox']").size()==$("#tBody input[type='checkbox']:checked").size()){
$("#checkAll").prop("checked",true);
} else {
$("#checkAll").prop("checked",false);
}
});该页面的数据来自jquery的拼接,这些数据全部拼接到tBody的标签框里
success:function (data) {
//显示市场活动列表
var htmlStr="";
$.each(data.clues,function (index,obj) {
htmlStr+="<tr class=\"active\">";
htmlStr+="<td><input type=\"checkbox\" /></td>";
htmlStr+="<td><a style=\"text-decoration: none; cursor: pointer;\" onclick=\"window.location.href='detail.html';\">"+obj.fullname+"</a></td>";
htmlStr+="<td>"+obj.company+"</td>";
htmlStr+="<td>"+obj.phone+"</td>";
htmlStr+="<td>"+obj.mphone+"</td>";
htmlStr+="<td>"+obj.source+"</td>";
htmlStr+="<td>"+obj.owner+"</td>";
htmlStr+="<td>"+obj.state+"</td>";
htmlStr+="</tr>";
});
$("#tBody").html(htmlStr);功能测试:
点击全选按钮

再次点击全选按钮

点击全选按钮后,点击一个数据项取消其勾选,全选按钮也会实时的进行取消勾选

边栏推荐
- People who lose weight should cry: it's no good not eating food, because your brain will be inflamed
- The two Nobel Prize winners became the chief scientist of the sky high price Baijiu of "taishanglaojun holding a dream"
- In depth analysis of yolov7 network architecture
- 滴滴 - dispatching
- 设计一个有getMin功能的栈
- Learn when playing No 1 | can live classroom still be like this? Come and unlock "new posture"!
- While (~scanf ("%d", & n)) is equivalent to while (scanf ("%d", & n)! =eof)
- How to do a good job in safety development?
- CAS操作
- Programmers can't play at the age of 35. Is it a fact or a misunderstanding?
猜你喜欢

VS2019 C# MFC安装

Check the computer restart times and reasons

475-82(230、43、78、79、213、198、1143)

Didi - dispatching

机器学习入门详解(一):理解监督学习中的最大似然估计

Open source, innovators win, 2022 "science and innovation China" open source innovation list selection is fully open!
Technical Analysis | Doris connector combined with Flink CDC to achieve accurate access to MySQL database and table exactly once

Network file storage system (II) practical operation of Minio distributed file system

475-82(230、43、78、79、213、198、1143)

Programmers can't play at the age of 35. Is it a fact or a misunderstanding?
随机推荐
Vs2019 C MFC installation
Hikaricp connection pool does not operate for a period of time, and the data is automatically disconnected
对无法重新创建的表进行了更改或者启用了“阻止保存要求重新创建表的更改”选项
ACNet:用于图像超分的非对称卷积(附实现code)
Didi - dispatching
Is the yield of financial products high or low?
Design a stack with getmin function
A review of nature: gender differences in anxiety and depression - circuits and mechanisms
Recommend 7 open source projects of yyds this week
[QNX hypervisor 2.2 user manual]9.3 CPU
Problems easily ignored by POM
P1049 [noip2001 popularization group t4] packing problem
Literature learning (part101) -- converge clustering
Leetcode (Sword finger offer) - 04. search in two-dimensional array
Using one stack to sort another stack
yolov7 网络架构深度解析
Summer Challenge harmonyos - slider slider for custom components
Programmers can't play at the age of 35. Is it a fact or a misunderstanding?
Google AI can't understand the comments of netizens, and the wrong meaning will be as high as 30%. Netizens: you don't understand my stem
Didi eta (estimate the travel time)