作者:C_z和 | 来源:互联网 | 2023-09-10 15:46
web前端|js教程JQuery,添加,并对web前端-js教程这次给大家带来JQuery动态操作表行并对新行添加事件,JQuery动态操作表行并对新行添加事件的注意事项有哪些,下
web前端|js教程
JQuery,添加,并对
web前端-js教程
这次给大家带来JQuery动态操作表行并对新行添加事件,JQuery动态操作表行并对新行添加事件的注意事项有哪些,下面就是实战案例,一起来看一下。
实现功能:大秀直播源码在线下载 迅雷下载地址,ubuntu怎么用网卡,tomcat7怎修改端口,爬虫 头文件,php获取系统时间戳,嘉兴新站seolzw
通常在编辑表格时表格的行数是不确定的,如果一次增加太多行可能导致页面内容太多,反应变慢;通过此程序实现表格动态增加行,一直保持最下面有多个空白行。
uemo源码,有效的vscode插件,ubuntu当服务器,如何重启 tomcat,qt 调用sqlite,旅游网页设计站点,首页数据库图片轮播,服务器租用30m,wordpress短链接插件,前端最快速开发框架,开源爬虫工具,php 文件缓存,焦大seo,springboot速度,帝国cms灵动标签内容,php投票网站模板,网页中图片自动切换,joomla创建模板,织梦后台怎么修改,手机禁止网页跳转页面跳转页面跳转,智睿管理系统,ecshop微信小程序lzw
效果:安卓记账源码,ubuntu 下网络命令,nutch爬虫工具流程,php 7.2.2,江西简爱seolzw
一:原始页面
二:表1增加新行并绑定timepicker
三:表2自动增加行,新行绑定timepicker
HTML源码:
.autoRows{ width: 350px; border:1px green solid; } .autoRows tbody tr td{ border-bottom:1px green solid; margin:0px; } .autoRows thead{ background-color:#8ec7d7; } .autoRows tfoot { background-color: #8ec7d7; }
表头1 | 表头1 | 表头1 |
表头2 | 表头2 | 表头2 |
| | |
| | |
| | |
表尾1 | 表尾2 | 表尾3 |
表头1 | 表头1 | 表头1 |
表头2 | 表头2 | 表头2 |
| | |
| | |
| | |
表尾1 | 表尾2 | 表尾3 |
$(function () { $(".autoRows").tableAutoRow(aaa); function aaa(row) { $(row).find(':text').timepicker(); } }); function addrow(obj) { $.fn.tableAutoRow.insertRow(obj); }
JS源码:
/// //为表格主体添加单击事件,当单击时添加行数,使表格保持有n个空行 (function ($) { $.fn.extend({ rowfunction: null, tableAutoRow: function (newRowFunction) { rowfunction = newRowFunction; return $(this).each(function () { var tb = this; if (!(this.tagName.toUpperCase() == "TBODY")) { if (!this.tBodies[0]) { return; } else { tb = this.tBodies[0]; } } //添加一个隐藏行,后面新增行复制此行 var lastRow = tb.rows[tb.rows.length - 1]; var row = $(lastRow).clone(true, true); $(row).insertAfter($(tb).find("tr:last")).hide(); //为除所有行添加事件,当获得焦点时自动增加新行 for (var i = 0; i 0) { var lastRow = tb.rows[tb.rows.length - 1]; for (var j = 0; j = 0; k--) { //node.options.remove(k); node.options[k].selected = false; } } break; case "checkbox": case "radio": if (isReset) { node.checked = node.defaultChecked; } else { node.checked = false; } break; } if (node.childNodes && node.childNodes.length > 0) { var l = node.childNodes.length; for (var i = 0; i