自己闲来无聊,写了一篇关于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. AutoCAD 2014 在Server 2008 中 十字光标很慢

    另外,请在你们的Windows Server上增加如下注册表: On      both Windows Server 2008 R2 and Windows Server 2012 create E ...

  2. opengl 和 vs2010的安装配置

    1.先安装vs2010, 输个激活秘钥 2.Windows 7下OpenGL如何配置,配置glut:    http://jingyan.baidu.com/article/b0b63dbfd1c08 ...

  3. 22. Generate Parentheses (recursion algorithm)

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  4. Cogs 1995. Yukari

    1995. Yukari ★★☆   输入文件:camera.in   输出文件:camera.out   简单对比时间限制:1 s   内存限制:128 MB 题目背景: 幻想乡的创始人之一,八云紫 ...

  5. 洛谷P1164 小A点菜(01背包求方案数)

    P1164 小A点菜 题目背景 uim神犇拿到了uoi的ra(镭牌)后,立刻拉着基友小A到了一家……餐馆,很低端的那种. uim指着墙上的价目表(太低级了没有菜单),说:“随便点”. 题目描述 不过u ...

  6. Mac 安装flutter 踩坑记

    完整版请看链接: http://b36d5043.wiz03.com/share/s/2Prl132RpQ3x2XpA4I2oTa2204K0FF0vB4J42tWIEQ04UrAg 首先下载flut ...

  7. EIGRP-8-路由器的邻接关系

    EIGRP路由器之间会建立并维护邻接关系.EIGRP在默认情况下会动态发现邻居路由器.也可以通过工程师手动配置(静态)发现邻居.   通过向目的组播组地址224.0.0.10或FF02: : A发送E ...

  8. JMETER进行REST API测试(分步指南)

    我确定你在这里是因为你需要加载测试Json Rest API.这并不奇怪,因为Rest API现在越来越受欢迎. 这本指南的目的:帮助您进行负载测试一个Json的 REST API 通过一个具体的例子 ...

  9. 导入别的类中的bean

    @Configuration class CommonContext { @Bean public MyBolt myBolt() { return new MyBolt(); } } ... @Co ...

  10. linux读取yaml文件的某个属性值

    trigger=$(cat test.yaml | grep "trigger" | awk '{print $2}') 该条命令的意思是:读取test.yaml文件中的trigg ...