简单教程
提交运行
代码编辑器:
<script> function displayResult(){ var firstRow=document.getElementById("myTable").rows[0]; var x=firstRow.insertCell(-1); x.innerHTML="New cell" } </script> <table id="myTable" border="1"> <tr> <td>First cell</td> <td>Second cell</td> <td>Third cell</td> </tr> </table> <br> <button type="button" onclick="displayResult()">插入单元格</button>
运行结果: