向一个已有的行中插入单元格
- <html>
- <head>
- <script type="text/javascript">
- function insCell()
- {
- var x=document.getElementById('tr2').insertCell(0)
- x.innerHTML="John"
- }
- </script>
- </head>
- <body>
- <table border="1">
- <tr id="tr1">
- <th>Firstname</th>
- <th>Lastname</th>
- </tr>
- <tr id="tr2">
- <td>Peter</td>
- <td>Griffin</td>
- </tr>
- </table>
- <br />
- <input type="button" onclick="insCell()" value="插入单元">
- </body>
- </html>