jquery复制当前tr行
//复制
var vBudgetCompileObj = (function() {
/*table新增/移除行,参数:tableId*/
var getMaxIndex;
var funGenerateRow = function(tableId) {
$("a[name='CopyTr'],a[name='DelTr']").unbind("click").click(function() {
var index = getMaxIndex() + 1;
console.log("index:" + index);
if ($(this).attr("name") == "CopyTr") {
var newHidden = $('<input type="hidden" name="tbBudCode.index" value="' + index + '">');
var newTr = $('<tr>').addClass("tr_row");
newTr.html($(this).parents('tr').html());
$('select', newTr).next('div').remove();
$(this).parents('tr').after($(newTr));
newTr.before(newHidden);
/*循环 修改input控件id和name*/
newTr.find("input.eaBudcode").each(function () {
$(this).attr("id", "tbBudCode" + index );
$(this).attr("name", "tbBudCode" + index );
});
newTr.find("input.eaClientCode").each(function () {
$(this).attr("id", "tbClientCode" + index);
$(this).attr("name", "tbClientCode" + index);
});
newTr.find(".eaBudName").each(function () {
$(this).attr("id", "tbBudName" + index);
$(this).attr("name", "tbBudName" + index);
}); /*循环修改select控件的value、id和name*/
newTr.find("select.eaDept").each(function () {
$(this).attr("id", "ddlDept" + index);
$(this).attr("name", "ddlDept" + index);
});
newTr.find("select.eaBrand").each(function () {
$(this).attr("id", "ddlBrand" + index);
$(this).attr("name", "ddlBrand" + index);
});
newTr.find("select.eaBudItem").each(function () {
$(this).attr("id", "ddlBudItem" + index);
$(this).attr("name", "ddlBudItem" + index);
});
newTr.find("select.eaCompany").each(function () {
$(this).attr("id","ddlCompany"+ index);
$(this).attr("name","ddlCompany"+ index);
});
newTr.find("select.eaCurrency").each(function () {
$(this).attr("id", "ddlCurrency" + index);
$(this).attr("name", "ddlCurrency" + index);
});
$('select', newTr).chosen({ width : '100%' }); //初始化复制行下拉框
funGenerateRow(tableId);
} else {
if (confirm("是否删除?")) {
$(this).parents('tr').remove(); //移除行
}
}
//显示行号
var thisIndex = 0;
$("#" + tableId + " tbody>tr.tr_row").each(function() {
var $td = $(this).children('td');
thisIndex++;
var thisRowIndex = $('<span class="badge badge-info">' + thisIndex + '</span>');
$td.eq(0).html(thisRowIndex);
});
});
}
<table class = "table jtable table-bordered table-striped" id = "table_1" >
<thead>
<tr>
<th style = "width: 50px;" >序号</th>
<th style = "width: 150px;" >预算编号</th>
<th style = "width: 100px;" >参考编号</th>
<th style = "width: 220px;" >预算名称</th>
<th style = "width: 100px;" >部门</th>
<th style = "width: 100px;" >品牌</th>
<th style = "width: 100px;" >预算科目</th>
<th style = "width: 50px;" >公司</th>
<th style = "width: 100px;" >预算币种</th>
<th style="width: 50px;">操作</th>
</tr>
</thead>
<tbody>
<tr class = "tr_row" >
<td>
<span class="label label-sm label-success label-mini"> 1 </span>
</td>
<td>
<input class = "form-control input-sm txt-required valid eaBudcode" id = "tbBudCode" name = "tbBudCode" type = "text" value = "REHA1B1" placeholder = "支持系统生成/用户输入,系统内唯一即可"/>
</td>
<td>
<input class = "form-control input-sm eaClientCode" id = "tbClientCode" name = "tbClientCode" type = "text" value = ""/>
</td>
<td>
<textarea rows = "2" class = "form-control input-sm txt-required valid eaBudName" id = "tbBudName" name = "tbBudName" >雅培-华北-A&P-半年度预算</textarea>
</td>
<td>
<select class = "fk-select form-control eaDept" id = "ddlDept" name="ddlDept" ></select>
</td>
<td>
<select class = "fk-select form-control eaBrand" id = "ddlBrand" name="ddlBrand" >
</select>
</td>
<td>
<select class = "fk-select form-control eaBudItem" id = "ddlBudItem" name="ddlBudItem">
</select>
</td>
<td>
<select class = "fk-select form-control eaCompany" id = "ddlCompany" name="ddlCompany">
</select>
</td>
<td>
<select class = "fk-select form-control eaCurrency" id = "ddlCurrency" name="ddlCurrency" >
</select>
</td>
<td>
<div class="input-group btn-group-xs margin-bottom-5">
<span class="input-group-btn margin-top-5" data-title="faplus">
<a href="javascript:void(0);" class="btn default btn-xs" name="CopyTr" title="复制"><i class="fa fa-plus"></i></a>
</span>
<span class="input-group-btn " data-title="faplus">
<a href="javascript:void(0);" class="btn default btn-xs" name="DelTr" title="删除"><i class="fa fa-minus"></i></a>
</span>
</div>
</td>
</tr>
</table>
jquery复制当前tr行的更多相关文章
- jquery 动态添加表格行
jquery 动态添加表格行 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <h ...
- jQuery操作Table tr td常用的方法
虽然现在DIV+CSS进行页的布局大行其道,但是很多地方使用table还是有很多优势,用table展示数据是比较方便的,下面汇总了jQuery操作Table tr td常用的方法,熟记这些操作技巧,下 ...
- 汇总常用的jQuery操作Table tr td方法
虽然现在DIV+CSS进行页的布局大行其道,但是很多地方使用table还是有很多优势,用table展示数据是比较方便的,下面汇总了jQuery操作Table tr td常用的方法,熟记这些操作技巧,下 ...
- 扩充 jQuery EasyUI Datagrid 数据行鼠标悬停/离开事件(onMouseOver/onMouseOut)
客户需求: jQuery EasyUI Datagrid 用户列表鼠标悬停/离开数据行时显示人员头像(onMouseOver/onMouseOut) 如图所示,Datagrid 鼠标悬停/离开数据行时 ...
- 扩展 jQuery EasyUI Datagrid 数据行鼠标悬停/离开事件(onMouseOver/onMouseOut)
客户需求: jQuery EasyUI Datagrid 用户列表鼠标悬停/离开数据行时显示人员头像(onMouseOver/onMouseOut) 如图所示,Datagrid 鼠标悬停/离开数据行时 ...
- 用jquery控制表格奇偶行及活动行颜色
虽然jquery流行已经很多年了,一直都感觉很难,也没有花时间去学习它,只是偶尔哪天心血来潮了去看一点点,时隔多日又会忘得一干二净.最近用到表格奇偶行不同色,不得不去再看jquery,虽然感觉还是难, ...
- [Web 前端] Jquery 复制元素,并修改属性, 追加到另一个元素后面
cp from : https://blog.csdn.net/cooledi/article/details/52813668 jquery 复制元素,并修改属性 $('#ID').clone() ...
- js在table指定tr行上或底下添加tr行
js在table指定tr行上或下面添加tr行 function onAddTR(trIndex) { var tb = document.getElementB ...
- jquery点击tr换背景颜色
jquery点击tr换tr的背景颜色,table的id为db-list1jQuery(function() { jQuery("#db-list1 tr").click( func ...
随机推荐
- autoreleasing on a thread
So basically, if you are running on OS X 10.9+ or iOS 7+, autoreleasing on a thread without a pool s ...
- java arraylist int[] 转换
double no=Double.valueOf("str");int num4=(int)no;double no1=Double.parseDouble("str&q ...
- Oracle 自动生成hive建表语句
从 oracle 数据库导数到到 hive 大数据平台,需要按照大数据平台的数据规范,重新生成建表的 SQL 语句,方便其间,写了一个自动生成SQL的存储过程. ① 创建一张表,用来存储源表的结构,以 ...
- 【原创】数据处理中判断空值的方法(np.isnan、is np.nan和pd.isna)比较
转载请注明出处:https://www.cnblogs.com/oceanicstar/p/10869725.html 1.np.isnan(只有数组数值运算时可使用) 注意:numpy模块的i ...
- linux 编辑文档
本篇主要分享下vi 命令行的操作: vi /etc/sysconfig/iptabels 首先我们需要理解putty客户端的复制 粘贴 插入文档 退出等命令 复制:指在putty客户端中的选择复制 ...
- forEach 以及 IE兼容
语法 array.forEach(function(currentValue, index, arr), thisValue) 参数 参数 描述 function(currentValue, in ...
- RPC框架 - thrift 客户端
-------客户端程序 ------ 下载 下载 thrift 源代码包 下载 thrift 的bin包 准备描述文件(使用源代码包的示例文件) \thrift-0.10.0\tu ...
- day 71 Django基础六之ORM中的锁和事务
Django基础六之ORM中的锁和事务 本节目录 一 锁 二 事务 三 xxx 四 xxx 五 xxx 六 xxx 七 xxx 八 xxx 一 锁 行级锁 select_for_update(no ...
- commons-logging日志实现解耦
一.需要解耦 日志是实际应用中的一个重要部分,日志系统也有许多开源的实现,如java.util.logging, logback, log4j系列等. 在使用日志系统时,如果与具体 ...
- python3.7 倒计时
#!/usr/bin/env python __author__ = "lrtao2010" # python3.7 倒计时 import time for i in range( ...