当前位置:网站首页>第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);功能测试:
点击全选按钮

再次点击全选按钮

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

边栏推荐
- [recommended reading] a collection of super useful vulnerability scanning tools!
- Network file storage system (II) practical operation of Minio distributed file system
- Redis core principles
- Raspberry connects EC20 for PPP dialing
- The two Nobel Prize winners became the chief scientist of the sky high price Baijiu of "taishanglaojun holding a dream"
- Learn when playing No 1 | can live classroom still be like this? Come and unlock "new posture"!
- [unity introduction program] basic concepts GameObject & components
- Node+js build time server
- [paper notes] progressive layered extraction (PLE): a novel multi task learning (MTL) model for personalized
- Literature learning (part101) -- converge clustering
猜你喜欢
![[paper notes] next vit: next generation vision transformer for efficient deployment in real industry](/img/ea/56881999a90f9c65f5f8768f9574bd.png)
[paper notes] next vit: next generation vision transformer for efficient deployment in real industry

Didi - dispatching
![[unity entry plan] interface Introduction (1) -scene view](/img/88/dee292cb90cd740640018e7260107f.png)
[unity entry plan] interface Introduction (1) -scene view

Practical operation: elegant downtime under large-scale micro service architecture
![[unity introduction program] basic concept - preform prefab](/img/c6/aac7bffdf99073978f9b2f8ff15fbb.png)
[unity introduction program] basic concept - preform prefab

eval与assert一句话木马分析

文件详细操作

yolov7 网络架构深度解析

滴滴 - eta(Estimate the Travel Time)

Raspberrypico serial communication
随机推荐
Raspberry pie 4B parsing PWM
滴滴 - dispatching
Codeforces Round #809 Editorial(A,B,C)
机器学习理论及案例分析(part1)--机器学习基础
Machine learning theory and case analysis (Part2) -- Regression
7.24模拟赛总结
Redis core principles
[unity entry plan] interface Introduction (1) -scene view
Native form submission data
UNIPRO multi terminal deployment to meet customers' diversified needs
Advanced C language (XII) - dynamic memory management
Raspberry Pie 3 connected to WiFi
Niuke dynamic planning training
Oracle trigger creation
Didi eta (estimate the travel time)
How to obtain the intersection / subtraction / Union of two sets by MySQL
efcore在Saas系统下多租户零脚本分表分库读写分离解决方案
滴滴 - eta(Estimate the Travel Time)
The value of integer a after bitwise negation (~) is - (a+1)
How should enterprise users choose aiops or APM?