//复制
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行的更多相关文章

  1. jquery 动态添加表格行

    jquery 动态添加表格行 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <h ...

  2. jQuery操作Table tr td常用的方法

    虽然现在DIV+CSS进行页的布局大行其道,但是很多地方使用table还是有很多优势,用table展示数据是比较方便的,下面汇总了jQuery操作Table tr td常用的方法,熟记这些操作技巧,下 ...

  3. 汇总常用的jQuery操作Table tr td方法

    虽然现在DIV+CSS进行页的布局大行其道,但是很多地方使用table还是有很多优势,用table展示数据是比较方便的,下面汇总了jQuery操作Table tr td常用的方法,熟记这些操作技巧,下 ...

  4. 扩充 jQuery EasyUI Datagrid 数据行鼠标悬停/离开事件(onMouseOver/onMouseOut)

    客户需求: jQuery EasyUI Datagrid 用户列表鼠标悬停/离开数据行时显示人员头像(onMouseOver/onMouseOut) 如图所示,Datagrid 鼠标悬停/离开数据行时 ...

  5. 扩展 jQuery EasyUI Datagrid 数据行鼠标悬停/离开事件(onMouseOver/onMouseOut)

    客户需求: jQuery EasyUI Datagrid 用户列表鼠标悬停/离开数据行时显示人员头像(onMouseOver/onMouseOut) 如图所示,Datagrid 鼠标悬停/离开数据行时 ...

  6. 用jquery控制表格奇偶行及活动行颜色

    虽然jquery流行已经很多年了,一直都感觉很难,也没有花时间去学习它,只是偶尔哪天心血来潮了去看一点点,时隔多日又会忘得一干二净.最近用到表格奇偶行不同色,不得不去再看jquery,虽然感觉还是难, ...

  7. [Web 前端] Jquery 复制元素,并修改属性, 追加到另一个元素后面

    cp from  : https://blog.csdn.net/cooledi/article/details/52813668 jquery 复制元素,并修改属性 $('#ID').clone() ...

  8. js在table指定tr行上或底下添加tr行

    js在table指定tr行上或下面添加tr行 function onAddTR(trIndex)         {             var tb = document.getElementB ...

  9. jquery点击tr换背景颜色

    jquery点击tr换tr的背景颜色,table的id为db-list1jQuery(function() { jQuery("#db-list1 tr").click( func ...

随机推荐

  1. 使用bouncycastle进行DESede/DESeee/AES128/AES192/AES256的加解密

    前言 默认的jdk不支持DESeee的算法,本地化的JDK中配置有拦截规则,可以通过使用bouncycastle的jar包中的DESEngine类来进行DESeee算法的运算. DES的8字节加解密 ...

  2. 初学树套树:线段树套Treap

    前言 树套树是一个十分神奇的算法,种类也有很多:像什么树状数组套主席树.树状数组套值域线段树.\(zkw\)线段树套\(vector\)等等. 不过,像我这么弱,当然只会最经典的 线段树套\(Trea ...

  3. Opentsdb简介

    1.OpenTSDB介绍 1.1.OpenTSDB是什么?主要用途是什么? 官方文档这样描述:OpenTSDB is a distributed, scalable Time Series Datab ...

  4. 反转链表[剑指offer]之python实现

    输入一个链表,输出反转后的链表. 非递归实现: # -*- coding:utf-8 -*- # class ListNode: # def __init__(self, x): # self.val ...

  5. python_62_装饰器5

    import time def timer(func): #timer(test1) func=test1 def deco(*args,**kwargs): start_time=time.time ...

  6. 一些常用的集合工具的代码块(缓慢更新XD,更新了多属性过滤:) )

    更新记录 虽然经常放鸽子,但是还是要记录一下更新 2017.8.30 更新了listToMap的方法,现在可以指定多个属性进行分组了,例如你要指定一个学生集合,按照名字和年龄相同的放在一组,现在只要调 ...

  7. 微信小程序页面跳转绑定点击事件

    https://www.cnblogs.com/mrszhou/p/7931747.html

  8. linux网络编程之断点传输文件

    以下载链接"http://www.boa.org/boa-0.94.13.tar.gz"为例: 断点续传实验大概步骤: ===================== 1,使用geth ...

  9. NOIP2018 全国热身赛 第二场 (不开放)

    NOIP2018 全国热身赛 第二场 (不开放) 题目链接:http://noi.ac/contest/26/problem/60 一道蛮有趣的题目. 然后比赛傻逼了. 即将做出来的时候去做别的题了. ...

  10. linux下安装redis和使用

    http://www.linuxidc.com/Linux/2014-05/101979.htm