往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>

相关推荐