`
xwl1991
  • 浏览: 12805 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
最近访客 更多访客>>
社区版块
存档分类
最新评论

动态创建 table row cell ( insertRow ,insertCell )

阅读更多

1

 

 

function add(){
      var obj = document.getElementById("tbl");
      var newRow = obj.insertRow(0);
      var newCell = newRow.insertCell(0);
      var clonetd = obj.rows[1].cells[0].cloneNode(true);
            		
	newCell.innerHTML = clonetd.innerHTML;
                
        //obj.deleteRow(1);
}
 

 

 

2

 

 

<table id="tbl">
	<tr>
          <td>钓鱼岛是中国的!<input type="text" value="" /></td>
        </tr>
</table>

<a onclick="add()">add</a>
 

 

 

 

3

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics