angularJs表格添加删除
来源:互联网 发布:乱世佳人英文影评知乎 编辑:程序博客网 时间:2024/06/05 03:41
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script> <style> *{ margin: 0; padding: 0; } table{ border-collapse: collapse; margin-top:50px; } th,td{ width: 80px; height: 40px; line-height: 40px; text-align: center; border:1px solid #000; } </style> </head> <body> <input type="text" value="zs">姓名 <input type="text" value="20">年龄 <input type="text" value="女">性别 <button type="button" class="tj">提交</button><br/> <table> <thead> <tr> <th><inputtype="checkbox"class="checkAll">全选</th> <th>姓名</th> <th>年龄</th> <th>性别</th> <th>操作</th> </tr> </thead> <tbody> <!--<tr> <td><input type="checkbox"></td> <td>zs</td> <td>20</td> <td>nan</td> <td><button>删除</button></td> </tr>--> </tbody> </table> <script> //计数器 var n=0; $(".tj").click(function(){ var name=$("input").eq(0).val(); var age=$("input").eq(1).val(); var sex=$("input").eq(2).val(); var add="<tr><td><input type='checkbox'></td><td>"+name+"</td><td>"+age+"</td><td>"+sex+"</td><td><button>删除</button></td></tr>" $("table").append(add); }); /*$("tbody button").click(function(){ alert(0) })*/ $("tbody").on("click","button",function(){ $(this).parents("tr").remove(); }); //点击全选,下面的全部选择 $(".checkAll").click(function(){ //console.log($(this).prop("checked")); if($(this).prop("checked")==true){ $("tbody input").prop("checked",true); }else{ $("tbody input").prop("checked",false); } }); //下面的选择点击 $("tbody").on("click","input",function(){ if($(this).prop("checked")==true){ n++; }else{ n--; } if(n==$("tbody input").length){ $(".checkAll").prop("checked",true); }else{ $(".checkAll").prop("checked",false); } }); </script> </body> </html>
阅读全文
0 0
- angularJs表格添加删除
- angularJs 表格添加删除修改查询
- angularjs遍历集合添加值表格进行删除
- AngularJS表格数据全选反选批量删除,删除的数据添加到数组里
- AngularJS查询,删除,添加
- angularJs添加,删除,查询
- angularjs 删除 查询 添加
- 表格动态添加删除
- 动态添加删除表格
- 添加删除表格
- 制作表格,添加,删除
- 表格添加与删除
- angularjs 可添加+修改+删除
- AngularJS添加删除查询排序
- AngularJs添加删除排序Y
- 使用AngularJS修改、删除表格数据
- angularJS添加表格,通过过滤器查找
- 利用js添加表格,删除表格
- springWeb开题笔记
- Conjugate Gradient
- Jzoj4744 同余
- 【1200】判断三角形是否为直角三角形
- codevs 2370 小机房的树 (lca)
- angularJs表格添加删除
- ubuntu 16.04硬盘分区方案
- 浓墨重彩之MySQL-02-数据库结构
- 【容斥原理+逆元+组合数+费马小定理+快速幂】UVALive
- 1039. 到底买不买(20)
- 深度解析堆排序
- Ubuntu下安装Qt5.8
- 51nod 1134 最长递增子序列 DP
- php结合redis实现高并发下的抢购、秒杀功能的实例