表单的勾选删除
来源:互联网 发布:mac book air能吃鸡吗 编辑:程序博客网 时间:2024/05/19 13:16
<!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){4 $(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 删除div下重复的表单
- 链表单个节点的删除
- 公司-->超级链接跳转和表单提交,删除的表单提交和删除失败的提示信息
- js实现表单项的全选、反选以及删除操作
- 删除chrome的表单自动填充用的错误用户名。
- 动态添加删除表单
- 表单添加 删除 搜索
- 添加 删除 修改表单
- jQUery表单删除
- 表单注册并删除
- React实现表单数据的添加与删除
- jquery + php动态添加删除表单的方法
- 8.一个能自动提交和删除的表单
- Ajax 实现对查询出的表单进行删除/修改
- 致远OA强力清除已删除仍显示的表单
- 【案例】中国银联、光大银行基于区块链的可信电子凭证系统
- Expected one result (or null) to be returned by selectOne(), but found: 4
- Linux中表示“时间”的结构体和相关函数
- C#生成唯一值的方法汇总
- 根据电机位置对混合动力汽车的定义
- 表单的勾选删除
- cglib代理学习笔记
- 懒人读算法(三)-添加新区间
- 文件系统读写--page cache机制
- Android项目该如何选择targetSdkVersion
- 基于pf_ring特性的libpcap库安装与配置
- UIButton 扩大点击响应区域
- SSM综合项目实战(TTSC) -- day02 Dubbo注册中心,通用Mapper,分页插件
- 金融科技&大数据产品推荐:Hyperchain--国产自主可控的企业级联盟区块链平台