JQuery的表单的添加、删除
来源:互联网 发布:淘宝订单售后流程图 编辑:程序博客网 时间:2024/06/10 22:26
<!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></head><body> 姓名:<input type="text" id="np"> 年龄:<input type="number" id="pu"> 性别:<input type="text" id="ut" > <input type="button" value="添加" id="in" > <table> <tr> <th><input type='checkbox' id="ip">全选</th> <th> 姓名</th> <th> 年龄</th> <th> 性别</th> <th> 操作</th> </tr> </table> <script> var n=0; $("#in").click(function () { //获取输入的姓名 var xm= $("#np").val(); var nl= $("#pu").val(); var xb= $("#ut").val(); // alert( $("#np").val()) //创建节点 $("table").append("<tr>"+"<td>"+"<input type='checkbox'>"+"</td>"+"<td>"+xm+"</td>"+"<td>"+nl+"</td>"+"<td>"+xb+"</td>"+"<td>"+"<span>删除</span>"+"</td>"+"</tr>"); $("table tr td span").click(function () { //判断当前这个复选框被勾选了才能被删除 if($(this).parents("tr").find("input").prop("checked")==true){ $(this).parents("tr").remove(); } }); }); //给"全选"一个点击事件,如果全选就把添加的input都设为true $("#ip").click(function () { if($("#ip").prop("checked")==true){ $("tr td input").prop("checked",true); }else{ $("tr td input").prop("checked",false); } }); //把添加的input设置点击事件,在进行判断是否被勾选,计数器勾选一个就累计一个,然后判断input的长度和计数器是否相等,相等的话就把“全选的input勾选” $("table").on("click","input",function () { alert(0); if($(this).prop("checked")==true){ n++; }else{ n--; } if(n==$("tr td input").length){ $("#ip").prop("checked",true); }else{ $("#ip").prop("checked",false); } }); </script></body></html>
阅读全文
0 0
- JQuery的表单的添加、删除
- jquery + php动态添加删除表单的方法
- 动态的添加、删除表单
- jquery表单列表添加删除
- jQuery表单添加与删除..
- jquery动态添加表单删除表单
- jquery的动态添加删除
- jquery制作具有添加与删除功能的表单(转载加修改)
- jquery 删除div下重复的表单
- jquery table表格添加删除数据(含批量删除,全选全不选和简单的表单验证)
- 表单添加以及删除(jquery)
- jQuery表单验证添加数据删除数据
- Jquery实现表格行的添加、删除
- Jquery实现表格行的添加、删除
- jQuery添加/删除Select的Option项
- jquery 添加删除html 的常用方法
- Jquery实现表格行的添加、删除
- Jquery EasyUI的添加,修改,删除,查询
- 非常经典的按键处理程序
- mysql解锁
- 关于加速
- Thrift入门与实例
- 创建类
- JQuery的表单的添加、删除
- Fibonacciê数的递归算法
- Matlab——KUKA机器人
- Ana-conda
- windows安装Tensorflow
- 链式前向星
- LeetCode 120
- HDU 4313 最小生成树
- 问题:使用docker时报错“net/http: TLS handshake timeout”的解决方案