// 追加表格tr
$(function () {
$("#btnAdd").click(function () {
$("<tr><td>1</td> <td><input class='names' tepy='text' /></td> <td id='operation_id'>操作人</td> <td id='operation_time'><%=operatioss_time %></td><td><input type='checkbox' class='state' checked='checked' />启用</td> <td><input id='btn' type='button' onclick='Addata();' value='保存' style=' width:50px;height:32px;'/><input id='btnDelete' type='button' onclick='remove(this);' value='删除' style=' width:50px;height:32px;margin-left:5px'/></td></tr>").appendTo("#top1");
});
})
//删除追加的tr
function remove(element) {
var remove = $(element).parents("tr").remove();
if (remove=="remove") {
window.location.reload();
}
}
兼容怎么弄 求思路 代码
想限制它最多只能追加3到4个tr又怎么做? 求代码思路
添加或删除在谷歌里不行,建议谷歌里F12看下,有没有什么js错误。至于限制最多只能追加3-4个tr。这个只需要在增加的tr里加个特定的样式名。然后在每次增加的时候通过样式名取得tr的个数进行判断即可。 比方说 var trarray=$(".样式名").length;//这就是增加的tr的个数。
js没错 就是兼容性有问题 只兼容IE 其他都不行