js控制表格

来源:互联网 发布:js offset client 编辑:程序博客网 时间:2024/04/30 12:12
<form> <input type="button" onclick="addline()" value="增加一行"> <table border="1" id="test"> <tr> <td colspan="2"><input type="text" name="tt[]"></td> </tr> </table> <input type="submit"> </form> 

<script> function addline(content){ newline=document.all.test.insertRow(); newline.insertCell().innerHTML='<input type="text" name="tt[]"><input type="button" value="删除此行" onclick="del()">' } function del(){ document.all.test.deleteRow(window.event.srcElement.parentElement.parentElement.rowIndex); } </script>

 

用js来控制表格,添加和删除一行。 

原创粉丝点击