基本行: <table width="100%" class="tb" id="content">
<tr>
<td width="6%"><input type="hidden" name="id" id="id" /></td>
<td width="10%"><input type="text" name="minact" id="minact"
class="coninput911" parentname="month" />
</td>
<td width="10%"> < 用户数 < </td>
<td width="10%"><input type="text" name="maxact" id="maxact"
class="coninput911" parentname="month" />
</td>
<td width="10%">基本费用</td>
<td width="10%"><input type="text" name="basefees"
id="basefees" class="coninput911" parentname="month" />
</td>
<td width="7%">元/月</td>
<td width="10%"><input type="text" name="singlefees"
id="singlefees" class="coninput911" parentname="month" />
</td>
<td width="10%">元/月,终端</td>
<td width="10%"><input type="text" name="zhekou"
id="zhekou" class="coninput911" parentname="month" />
</td>
<td width="7%">%折扣 <input type="hidden" name="feesid"> </td>
</tr>
</table>
要复制的行<table class="tb1">
<tr>
<td width="6%">
<p id="remove" onclick="removeadd()">移除</p>
<input type="hidden" name="id" id="id" />
</td>
<td width="10%"><input type="text" name="minact" id="minact"
class="coninput911" parentname="month" /></td>
<td width="10%"> < 用户数 < </td>
<td width="10%"><input type="text" name="maxact" id="maxact"
class="coninput911" parentname="month" /></td>
<td width="10%">基本费用:</td>
<td width="10%"><input type="text" name="basefees"
id="basefees" class="coninput911" parentname="month" /></td>
<td width="7%">元/月,</td>
<td width="10%"><input type="text" name="singlefees"
id="singlefees" class="coninput911" parentname="month" /></td>
<td width="10%">元/月,终端</td>
<td width="10%"><input type="text" name="zhekou"
id="zhekou" class="coninput911" parentname="month" /></td>
<td width="7%">%折扣</td>
</tr>
</table>我的添加方法:$("#btnadd").bind('click', function() {
var tr = $(".tb1 tr").eq(0).clone(true);
// tr.find("td").get(0).innerHTML = ++i;
tr.show();
tr.appendTo($(".tb"));
});
});
现在我想要的一个效果是:添加多了几个空行,想删除掉,该如何实现?
<tr>
<td width="6%"><input type="hidden" name="id" id="id" /></td>
<td width="10%"><input type="text" name="minact" id="minact"
class="coninput911" parentname="month" />
</td>
<td width="10%"> < 用户数 < </td>
<td width="10%"><input type="text" name="maxact" id="maxact"
class="coninput911" parentname="month" />
</td>
<td width="10%">基本费用</td>
<td width="10%"><input type="text" name="basefees"
id="basefees" class="coninput911" parentname="month" />
</td>
<td width="7%">元/月</td>
<td width="10%"><input type="text" name="singlefees"
id="singlefees" class="coninput911" parentname="month" />
</td>
<td width="10%">元/月,终端</td>
<td width="10%"><input type="text" name="zhekou"
id="zhekou" class="coninput911" parentname="month" />
</td>
<td width="7%">%折扣 <input type="hidden" name="feesid"> </td>
</tr>
</table>
要复制的行<table class="tb1">
<tr>
<td width="6%">
<p id="remove" onclick="removeadd()">移除</p>
<input type="hidden" name="id" id="id" />
</td>
<td width="10%"><input type="text" name="minact" id="minact"
class="coninput911" parentname="month" /></td>
<td width="10%"> < 用户数 < </td>
<td width="10%"><input type="text" name="maxact" id="maxact"
class="coninput911" parentname="month" /></td>
<td width="10%">基本费用:</td>
<td width="10%"><input type="text" name="basefees"
id="basefees" class="coninput911" parentname="month" /></td>
<td width="7%">元/月,</td>
<td width="10%"><input type="text" name="singlefees"
id="singlefees" class="coninput911" parentname="month" /></td>
<td width="10%">元/月,终端</td>
<td width="10%"><input type="text" name="zhekou"
id="zhekou" class="coninput911" parentname="month" /></td>
<td width="7%">%折扣</td>
</tr>
</table>我的添加方法:$("#btnadd").bind('click', function() {
var tr = $(".tb1 tr").eq(0).clone(true);
// tr.find("td").get(0).innerHTML = ++i;
tr.show();
tr.appendTo($(".tb"));
});
});
现在我想要的一个效果是:添加多了几个空行,想删除掉,该如何实现?
$("#newBtn").bind("click", function(){
//alert($("input:checked"));
$("#myTable").append("<tr><td><input id=\"sd\" type=\"checkbox\" /></td><td><input type=\"text\" /></td></tr>");
alert(document.getElementById('sd').value);
});
$("#delBtn").bind("click", function(){
//alert($("input:checked"));
$("input:checked").parent().parent().remove();
});
});
是这样的,我多添加了几个table行,想把多余的删除掉。
在每个table行前面都有一个删除。
$(".tb1 tr").append("<td width='6%'><input name=\"sd\" type=\"checkbox\"/></td>");
使用jquery如下:
//删除新行
$(document).ready(function() {
$("#btndelnew").bind("click", function(){
alert($("input:checkbox:checked"));
$("input:checkbox:checked").parent().parent().remove();
});
});