日期:2014-05-16 浏览次数:20339 次
<table border="1"> <tr> <td colspan="2" align="right"> <input name="addButton" value="添加" type="button" onclick="addRow(this)"> </td> </tr> <tr> <td>label</td> <td><input name="aaa"><input name="deleteRow" type="button" value="delete" onclick="deleteRow(this)"></td> </tr> </table> <script language=javascript> function addRow(obj) { var objTbody=obj.parentNode.parentNode.parentNode var objTr=obj.parentNode.parentNode.nextSibling objTbody.appendChild(objTr.cloneNode(true)) } function deleteRow(obj) { var objTr=obj.parentNode.parentNode var objTbody=objTr.parentNode if(objTbody.childNodes.length>2) { objTr.removeNode(true) } } </script>