全选全不选案例table表格

案例一纯table表格

<table class="table table-bordered">
<thead class="aa">
<tr>
<th>品类</th>
<th>计量单位</th>
<th>积分</th>
<th>最后修改时间</th>
<th>修改人</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>废纸</td>
<td>kg</td>
<td>1</td>
<td></td>
<td></td>
<td>
<span class="glyphicon glyphicon-credit-card sp"></span ><span class="sp"> 查看</span>
<span class="glyphicon glyphicon-pencil sp"></span><span class="sp"> 编辑&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span class="glyphicon glyphicon-trash sp"></span><span class="sp"> 删除&nbsp;&nbsp;&nbsp;&nbsp;</span>
</td>
</tr>
<tr>
<td>塑料瓶</td>
<td>个</td>
<td>1</td>
<td></td>
<td></td>
<td>
<span class="glyphicon glyphicon-credit-card sp"></span ><span class="sp"> 查看</span>
<span class="glyphicon glyphicon-pencil sp"></span><span class="sp"> 编辑&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span class="glyphicon glyphicon-trash sp"></span><span class="sp"> 删除&nbsp;&nbsp;&nbsp;&nbsp;</span>
</td>
</tr>
<tr>
<td>厨余</td>
<td>次</td>
<td>1</td>
<td></td>
<td></td>
<td>
<span class="glyphicon glyphicon-credit-card sp"></span ><span class="sp"> 查看</span>
<span class="glyphicon glyphicon-pencil sp"></span><span class="sp"> 编辑&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span class="glyphicon glyphicon-trash sp"></span><span class="sp"> 删除&nbsp;&nbsp;&nbsp;&nbsp;</span>
</td>
</tr>
</tbody> </table>

图一图二如下所示

案例二table表格及全选全不选

<table class="table table-bordered">
<thead class="aa">
<tr>
<th>
<input type="checkbox" id="selectAll" />
</th>
<th>街道</th>
<th>小区</th>
<th>楼号</th>
<th>单元</th>
<th>门牌号</th>
<th>二维码</th>
<th>发卡时间</th>
</tr>
</thead>
<tbody id="tbodyss">
<tr>
<th>
<input type="checkbox" name="check" />
</th>
<td>知春路</td>
<td>世纪花园</td>
<td>1</td>
<td>1</td>
<td>101</td>
<td>150329002842997</td>
<td>2019-7-31 </td>
</tr>
<tr>
<th>
<input type="checkbox" name="check" />
</th>
<td>知春路</td>
<td>世纪花园</td>
<td>1</td>
<td>1</td>
<td>101</td>
<td>150329002842997</td>
<td>2019-7-31 </td>
</tr>
<tr>
<th>
<input type="checkbox" name="check" />
</th>
<td>知春路</td>
<td>世纪花园</td>
<td>1</td>
<td>1</td>
<td>101</td>
<td>150329002842997</td>
<td>2019-7-31 </td>
</tr>
</tbody>
</table>

js代码

$(function(){
var selectAll=$("#selectAll")
selectAll.click(function(){
if (selectAll.prop("checked") == true) {
// 上面的复选框已被选中
$(":checkbox[name='check']").prop("checked", true);
} else {
// 上面的复选框没被选中
$(":checkbox[name='check']").prop("checked", false);
}
})
$("#tbodyss :input").click(function(){
//获取复选框的个数
var length1=$("#tbodyss :input").length
//获取选中的复选框的个数
var length2=$("#tbodyss :checked").length
if(length1 == length2){
$("#selectAll").prop("checked",true);
}else{
$("#selectAll").prop("checked",false);
}
}) })

全选全不选案例table表格的更多相关文章

  1. 九九乘法表,全js编写,放入table表格带入页面渲染出来

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. Jquery 遍历 Table;遍历CheckBox ;遍历Select;全选/全不选

    关于Jquery:相信大家已经很熟悉了,我最近的项目运用到关于Jquery的遍历事件:权当总结下: 遍历Table <table  id="thistab"> < ...

  3. 原生JS实现全选和不全选

    案例演示 源代码 <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...

  4. Dynamic CRM 2013学习笔记(二十六)报表设计:Reporting Service报表 动态参数、参数多选全选、动态列、动态显示行字体颜色

    上次介绍过CRM里开始报表的一些注意事项:Dynamic CRM 2013学习笔记(十五)报表入门.开发工具及注意事项,本文继续介绍报表里的一些动态效果:动态显示参数,参数是从数据库里查询出来的:参数 ...

  5. jQuery/javascript实现全选全不选

    <html> <head> <meta charset="utf-8"> <title>Checkbox的练习</title& ...

  6. jQuery实现Checkbox中项目开发全选全不选的使用

    <html> <head> <meta charset="utf-8"> <title>Checkbox的练习</title& ...

  7. Jq 遍历 全选 全不选 反选

    //全选 全不选 $('#checkAll').click(function () { //判断是否被选中 var bischecked = $('#checkAll').is(':checked') ...

  8. javascript实现复选框的全选全不选

    通过复选框的id获取到复选框 元素 对复选框绑定点击事件 每个checkbox都设置相同的name checkOne 通过得到的元素获取checkbox的状态 当点击全选全不选checkbox时,检查 ...

  9. VUE实现简单的全选/全不选

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

随机推荐

  1. PHP系列 | [转] PHP中被忽略的性能优化利器:生成器

    官方:https://www.php.net/manual/zh/language.generators.overview.php 原文:https://segmentfault.com/a/1190 ...

  2. CAS单点登录源码解析之【客户端】

    cas 3.5.3服务器搭建+spring boot集成+shiro模拟登录(不修改现有shiro认证架构).因为我们属于供应商,所以有些客户那里会需要接对方的CAS,所以没有使用shiro和cas的 ...

  3. 两款不错的js甘特图控件

    dhtmlx:https://docs.dhtmlx.com/ jQuery.Gantt:http://taitems.github.io/jQuery.Gantt/

  4. RocketMQ安装部署

    一.简介RocketMQ RocektMQ是阿里巴巴在2012年开源的一个纯java.分布式.队列模型的第三代消息中间件,不仅在传统高频交易链路有着低延迟的出色表现,在实时计算等大数据领域也有着不错的 ...

  5. mqtt概念整理

    运行模式: 服务器: emqx (https://docs.emqx.io/edge/v3/cn/install.html) 协议头字节数: 2个字节 三种消息可能性保障(Qos): Qos0:最多一 ...

  6. 求解未知数——yjy题库

    /* 未知数 p1,p2,p3,p4,p5,满足: (1) p1 与 p3 均为 2 位的正整数:p5 为 3 位的正整数: (2) p2 与 p4 低两位(例:数值‘123’取低两位则为‘23’)数 ...

  7. pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your path

    使用pytesseract识别验证码中遇到异常如下: pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installe ...

  8. @vue/cli 4.1.1安装

    按照安装步骤,先卸载,再安装,最终,查看vue -V 的版本都是3.8.2,也就是说并没有安装成功,于是,考虑用yarn去安装 1,首先清除缓存: yarn cache clean 2,yarn设置淘 ...

  9. Web API之Web Components

    本文参考<你的前端框架要被web组件替代了>. 于2011年面世的Web Components是一套功能组件,让开发者可以使用 HTML.CSS 和 JavaScript 创建可复用的组件 ...

  10. ASP.Net validator

    <asp:TextBox ID="txtTransitDays" runat="server"></asp:TextBox> <a ...