js+dom增加删除表格行代码
js+dom增加删除表格行代码
<table id="tbl" width="300" name="tbl" border="1">
<tr>
<td width="160">content</td>
<td>name</td>
<td><input type="button" value="add" onclick="insert_row()"></td>
</tr>
</table>
<script language="javascript">
var i=0
function insert_row(){
i++
R=tbl.insertRow()
C=R.insertCell()
C.innerHTML="<input type='text' name='name'>"
C=R.insertCell()
C.innerHTML="name"+i
C=R.insertCell()
C.innerHTML="<input type='button' value='delete' onclick='tbl.deleteRow("+(i-1)+")'>"
}
</script>
补充:网页制作,设计基础