六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 34|回复: 0

javascript操作table

[复制链接]

升级  19.33%

19

主题

19

主题

19

主题

秀才

Rank: 2

积分
79
 楼主| 发表于 2013-1-29 09:27:19 | 显示全部楼层 |阅读模式
<html>  <body>       <body>   <table name="tab" id="tab">      <tr>     <td>测试</td> <td>test</td>  </tr>     </table>   <input type="button" value="增加行" />   <input type="button" value="删除行" /> <script>    function insert(){    var tab1=document.getElementById("tab");var tr =tab1.insertRow();var tb1 =tr.insertCell(0);var tb2 =tr.insertCell(1);tb1.innerHTML="<input type='text' name='username' id='username' value='新增列1'/>";tb2.innerHTML="<input type='text' name='username' id='username' value='新增列2'/>";    }function del(){   var alltr=document.getElementsByTagName("tr");   var tab=document.getElementById("tab");;   tab.deleteRow(alltr.length-1);   }//insert() </script>   </body></html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表