自己闲来无聊,写了一篇关于jq选中复选框删除数据的一个功能,不足之处,还望多多包涵

js代码

<script type="text/javascript" src="jquery.min.js"></script>

<script type="text/javascript">

$(document).ready(function() {
$("button").click(function(){
$(":checked").parent().parent().fadeOut("show"); //隐藏所有被选中的input元素
// $(":checked").parent().parent().remove(); //删除所有被选中的input元素
//parent() 获得当前匹配元素集合中每个元素的父元素,
})
$("tr").mousemove(function(){
$(this).css("background","#F0F0F0"); //鼠标经过背景颜色变为灰色
})
$("tr").mouseout(function(){
$(this).css("background","#fff"); //离开后背景颜色回复白色
})
$("#button1").click(function(){
$(":checkbox").attr("checked",true); //设置所有复选框默认勾选
})
$("#button2").click(function(){
$(":checkbox").attr("checked",false); //设置所有复选框未勾选
})
}); </script>

在这里我为了制作一个表格,所以写了点CSS代码,跟html代码

<style>

table{ border-collapse: collapse; border:1px solid #FFFFFF}

table td{ text-align:center; height:30px; font-size:12px; line-height:30px; border:1px solid #efecec}
#test tr td{ text-align:center; height:30px; font-size:12px; line-height:30px; border:1px solid #efecec}
</style>

这里写了一个简单表格,可以参考一下

<table width="1000px" border="0" cellspacing="0" cellpadding="0" style="margin:0 auto">

  <tbody>

    <tr>

      <td width="26%"><input type="button" name="button" id="button1" value="全选">

      <input type="button" name="button2" id="button2" value="反选"></td>

      <td width="57%"><button>点击删除选中的表格 </button></td>

      <td width="17%">1</td>

    </tr>

    <tr>

      <td width="26%"><input type="checkbox" name="checkbox" id="1"></td>

      <td width="57%">第一行</td>

      <td width="17%">1</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox2" id="2"></td>

      <td>第二行</td>

      <td>2</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox3" id="3"></td>

      <td>第三行</td>

      <td>3</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox4" id="4"></td>

      <td>第四行</td>

      <td>4</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox5" id="5"></td>

      <td>第五行</td>

      <td>5</td>

    </tr>

      <tr>

      <td><input type="checkbox" name="checkbox3" id="3"></td>

      <td>第六行</td>

      <td>6</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox4" id="4"></td>

      <td>第七行</td>

      <td>7</td>

    </tr>

    <tr>

      <td><input type="checkbox" name="checkbox5" id="5"></td>

      <td>第八行</td>

      <td>8</td>

    </tr>

  </tbody>

</table>

分享一下页面效果图,大家可以参考,将代码复制本地,就可以运行看效果

有不足之处还望大家海涵,有更好的方式可以一起探讨

Jquery删除table里面checkbox选中的多个行的更多相关文章

  1. Jquery如何删除table里面checkbox选中的多个行

    思路:遍历被选中的checkbox对象→根据选中项筛选出需要删除的行→删除行.实例说明如下: 1.HTML结构 <table id = "test_table"> &l ...

  2. 【2017-07-03】JS连续删除table中的选中的多行数据

    deleteRow() 连续删除多行 应用:删除表格选中的一行或多行.html代码如下: <table > <tr> <td >复选框</td> < ...

  3. jquery设置和获得checkbox选中问题

    1.设置checkbox选中: //选中多选框 checkbox=$("#agentinfo input[name='veri[]']"); //循环多选框中的值 checkbox ...

  4. jquery 删除table行,该如何解决

    query 删除table行< table >  < tbody >  < tr >  < td > 这行原来就有 </ td >  < ...

  5. jquery和bootstrap获取checkbox选中的多行数据

    在项目中,经常遇到,于是整理 引用bootstrap的js和css 代码解释: $("#dgFlowList").find(":checkbox:checked" ...

  6. jQuery radio change事件 checkbox选中事件

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. jquery 实现table的行列选中效果改进

    行列都可以多选,也可对相应数据进行统计: 行选中效果 列选中效果

  8. 前端开发学习之——使用jquery/javascript判断及改变checkbox选中状态

    一.使用jquery判断及改变checkbox选中状态 1.使用JQuery判断一个checkbox 是否为选中: (1).attr('checked) 看JQuery版本1.6+返回:”checke ...

  9. jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中

    jQuery获取Select选择的Text和Value: 语法解释: 1. $("#select_id").change(function(){//code...}); //为Se ...

随机推荐

  1. Entity Framework Code-First(9.3):DataAnnotations - ConcurrencyCheck Attribute

    ConcurrencyCheck Attribute: ConcurrencyCheck attribute can be applied to a property of a domain clas ...

  2. LeetCode: 455 Assign Cookies(easy)

    题目: Assume you are an awesome parent and want to give your children some cookies. But, you should gi ...

  3. Haproxy+Keepalived高可用配置

    基本实验 参考文档 博文地址 环境拓扑 下面使我们要实现的负载均衡集群图示 主节点地址: 92.0.0.11 从节点地址: 92.0.0.12 共享虚拟地址:92.0.0.8 下面是负载均衡集群可能出 ...

  4. Ansible Playbooks高级使用

    文件操作 文件创建 file 用于设置文件/链接/目录的属性,或者删除文件/链接/目录 ### state如果是directory当目录不存在时会自动创建:如果是file当文件不存在时不会自动创建 - ...

  5. Linux中关机和磁盘管理命令

    常用的关机命令 shutdown -h 关机 -r 重启 halt poweroff reboot 重启 logout 退出登录命令 磁盘管理命令 df -h 以1024进制计算最合适的单位显示磁盘容 ...

  6. 配置OpenCV报应用程序无法正常启动0xc000007b

    我的配置软件是OpenCV3.4.1和visual studio2017.参考这篇博客(https://blog.csdn.net/qq_41175905/article/details/805604 ...

  7. 2018CCPC网络赛A(优先队列,思维)

    #include<bits/stdc++.h>using namespace std;priority_queue<pair<int,int>>q;int main ...

  8. go语言web开发框架_Iris框架讲解(五)MVC包使用

    在Iris框架中,封装了mvc包作为对mvc架构的支持,方便开发者遵循mvc的开发原则进行开发. iris框架支持请求数据.模型.持久数据分层处理,并支持各层级模块代码绑定执行. MVC即:model ...

  9. 解决Maven项目中jar包依赖冲突问题

    版本冲突的解决方案 [1]调节原则 [1]路径最短者优先原则 [2]路径相同时,先声明者优先原则 [2]排除原则:用于排除某项依赖的依赖jar包 <dependency> <grou ...

  10. mongodb you can't add a second

    问题信息: Due to limitations of the com.mongodb.BasicDBObject, you can't add a second 'createTime' expre ...