往table表格里面插入一行tr 兼容IE8
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
</script>
</head>
<body>
<table id="table1" border="1">
<tr>
<td>first</td>
</tr>
<tr>
<td>two</td>
</tr>
</table>
<div class="loading-indicator" style="height: 100px"></div>
<div id="tree_id" style="width: 100px; height: 100px; background: red" onclick="tableClick()">点击我</div>
</body>
<script type="text/javascript">
function tableClick(){
var oTable=document.getElementById('table1');
var tr = document.createElement("tr");
var td = document.createElement("td");
td.innerHTML="append tr";
tr.appendChild(td);
oTable.appendChild(tr); // chrom 浏览器
oTable .outerHTML = oTable .outerHTML; // 兼容Ie8
}
</script>
</html>
相关推荐
表格的现在还是较为常用的一种标签,但不是用来布局,常见处理、显示表格式数据。在HTML网页中,要想创建表格,就需要使用表格相关的标签。<table> <tr> <td>单元格内的文字</td> ...