//HTML
<a href="javascript:void(0)" onclick="AddAttachment()">[点击添加附件]</a>
<table cellpadding="0" cellspacing="3" id="id_attachmentpanel"></table>
=========================================================
//新增文章页面
function AddAttachment() {
var objTable = $("#id_attachmentpanel");
var intCount = $("#id_attachmentpanel tr").children().size() / 2 + 1;
if (intCount > 5) { alert("附件不能超过5个"); return; }
objTable.append("<tr><td>" + intCount + ". <input type='file' name='file" + intCount + "' onchange='FileExtChecking(this,1)' /></td><td><a href='javascript:void(0)' onclick='AddAttachment()'>[增加]</a><a href='javascript:void(0);' onclick='DisposeTr(this)'>[取消]</a></td></tr>");
$("#id_attachmentpanel a").hide();
$("#id_attachmentpanel a").last().show();
if (intCount < 5) { $("#id_attachmentpanel a").last().prev().show(); }
}
function DisposeTr(arg_obj_item) {
var objTr = $(arg_obj_item).parent().parent();
objTr.remove();
$("#id_attachmentpanel a").last().show();
$("#id_attachmentpanel a").last().prev().show();
}
============================================================
//编辑文章页面
function AddAttachment() {
var intAttach = '<%=intAttach %>';
var objTable = $("#id_attachmentpanel");
var intCount = $("#id_attachmentpanel tr").children().size() / 2 + 1;
if (intCount > (5-intAttach)) { alert("附件不能超过5个"); return; }
objTable.append("<tr><td>" + intCount + ". <input type='file' name='file" + intCount + "' onchange='FileExtChecking(this,1);' /></td><td><a href='javascript:void(0)' onclick='AddAttachment()'>[增加]</a><a href='javascript:void(0);' onclick='DisposeTr(this)'>[取消]</a></td></tr>");
$("#id_attachmentpanel a").hide();
$("#id_attachmentpanel a").last().show();
if (intCount < (5-intAttach)) { $("#id_attachmentpanel a").last().prev().show(); }
});
function DisposeTr(arg_obj_item) {
var objTr = $(arg_obj_item).parent().parent();
objTr.remove();
$("#id_attachmentpanel a").last().show();
$("#id_attachmentpanel a").last().prev().show();
}
==========================================
分享到:
相关推荐
主要介绍了jQuery+ajax实现动态添加表格tr td功能,结合实例形式分析了jQuery基于ajax动态创建页面table元素相关操作技巧,需要的朋友可以参考下
本文实例讲述了jQuery实现动态添加tr到table的方法。分享给大家供大家参考,具体如下: 运行效果图如下: 完整代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ...
基于Jquery的前台按表头排序table tr th
本文实例讲述了jQuery实现为table表格动态添加或删除tr功能。分享给大家供大家参考,具体如下: HTML页面元素如下: <!-- 订单明细dialog --> 销售订单明细 xss=removed> <table class=exhibit_table id=...
最近由于项目的需要,需要动态的添加和删除table中的tr,感觉用JS可以实现,但是在网上找了一下,单纯的自己写JS,感觉太...这篇文章给大家用实例介绍了jQuery动态添加与删除tr行的方法,有需要的朋友们可以参考借鉴。
JQuery动态生成Table表格 主要用到了JQuery中的append和appendto的方法,具体代码如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>...
利用css和jquery实现table表头固定(浮动)显示,不复制表格内容,不更改页面元素,完全通过js设置样式来实现。
table tr 改变列宽 jquery
本文实例讲述了jQuery实现动态给table赋值的方法。分享给大家供大家参考,具体如下: html 请忽视各种class,因为前端用的是layui <table class=layui-table lay-skin=line id=datas> <tr> 昵称 ...
本文实例为大家分享了jQuery实现动态添加标签事件的具体代码,供大家参考,具体内容如下 代码: <body> <table id="tableID" border="1" align="center" width="60%"> <tr> 用户名</th> 密码</th> 操作...
<table class=exhibit_table xss=removed> <tr> 上传计划单 <td xss=removed><input type=file name=file style=display:inline; width:180px;/> <button type=button class=btn btn-success btn-xs ...
本文实例讲述了jQuery实现html table行Tr的复制、删除、计算功能。分享给大家供大家参考,具体如下: 添加行: function addtr(){ var tr = $(#tb tr).eq(0).clone(); tr.appendTo(#tb); //tr.insertBefore(#tb ...
jquery实现递归table-tr,可并记录tr对应的index,写入Array中,方便后期处理。 jquery实现递归table-tr,可并记录tr对应的index,写入Array中,方便后期处理。
能够自定义tr的位置,便于排序操作,000000000
NULL 博文链接:https://shihuan830619.iteye.com/blog/1169666
jquery table 横竖列的求总和,jquery table 横竖列的求总和,jquery table 横竖列的求总和 参考 var lastTr = []; $("#table").find("tr").each(function(j, e){ if(j == 0){ return true
//得到表格ID=TbData的jquery对象 //所有的数据行有一个.CaseRow的Class,得到数据行的大小 var vNum=$(“#TbData tr”).filter(“.CaseRow”).size()+1;//表格有多少个数据行 var vTr=$(“#TbData #trDataRow1”); /...