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 ...
随机推荐
- POJ 3181 Dollar Dayz(递推,两个long long)
题意:John有N美元,有价格为1~K的工具,可以买的个数不限,问1~K组合出N的方案数. f[i = 第i中工具][j = 花费为j] = 方案数. f[i][j] = sigma{ f[i-1][ ...
- POJ-2226 Muddy Fields---二分图匹配+巧妙构图
题目链接: https://vjudge.net/problem/POJ-2226 题目大意: 用宽度为1长度不限的木板将水洼‘*’盖住而不盖住草‘.' Sample Input 4 4 *.*. . ...
- python 多进程简单调用
python 多进程简 #!/usr/bin/env python #-*- coding:utf-8 -*- # author:leo # datetime:2019/5/28 10:03 # so ...
- AngularJs学习笔记-数据绑定、管道
数据绑定.管道 (1)数据绑定(Angular中默认是单向绑定) 1.[]方括号 可以用于子组件传值 由于是单向绑定,所以当子组件中的iStars属性发生改变时,不会影响到父组件中product.ra ...
- Drupal忘记管理员密码
第一步:登陆录到phpmyadmin(通用的mysql数据库管理工具),进入phpmyadmin后,找到与drupal7相关联数据库并在数据库中找到一张名为“users”的表,然后选择浏览. 第二步: ...
- SVN不显示状态图标
1,输入win+R,输入regedit,调出注册表信息 2,按下Ctrl+F,在注册表里搜索“ShellIconOverlayIdentifiers” 3,将TortoiseAdded.Tortois ...
- 1043: [HAOI2008]下落的圆盘
Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1725 Solved: 743[Submit][Status][Discuss] Descripti ...
- ES6箭头函数基本用法
ES6箭头函数基本用法 ``` window.onload = function(){ alert(abc); } //箭头函数 window.onload = ()=>{ alert(&quo ...
- 判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备)
判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备) // ===== 判断浏览器环境 ===== // // 判断是否是QQ环境 function isQQ() { retur ...
- .net core 在IIS上发布502问题
本来迁移一个项目到.net core就是一件体力活,要找各种替代包,还有一些函数/属性的不支持 总之很头疼... 不要问我为什么用了.net core还要Host在IIS上,国内用.net的公司普遍都 ...