利用js动态生成table
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>js添加表格行列</title>
- <mce:script type="text/javascript">
- function insert(){
- var tb=document.getElementById("mytable");
- for(var i=0;i<3;i++){
- var tr = tb.insertRow();
- var td1 = tr.insertCell(0);
- var td2 = tr.insertCell(1);
- td1.innerHTML = "name";
- td2.innerHTML = "password";
- }
- }
- // --></mce:script>
- </head>
- <body>
- <table id="mytable">
- <tr>
- <td width="100">第一列</td>
- <td width="100">第二列</td>
- </tr>
- </table>
- <input type="submit" onclick="insert()" value="添加"/>
- </body>
- </html>