jsはie 8の下で表trのbugを動的に増加します.
1311 ワード
<html>
<body>
<table id="mytable">
<tr>
<th >adf</th>
<th >123</th>
<th >342</th>
<th >4545</th>
</tr>
</table>
<script>
var fragment = document.createDocumentFragment();
var tableElement = document.getElementById("mytable");
alert(tableElement .innerHTML); // <TBODY><TR>.....</TR></TBODY>
alert(tableElement .outerHTML);// <TABLE id=mytable><TBODY><TR>...</TR></TBODY></TABLE>
for (var i=0; i<10; i++) {
var tr = document.createElement("tr");
for (var j=0; j<4; j++) {
var td = document.createElement("td");
td.innerHTML = "111";
tr.appendChild(td);
fragment.appendChild(tr);
}
}
tableElement .appendChild(fragment);
// , ie8 tr, firefox
// ie , tableElement .outerHTML = tableElement .outerHTML append
if(document.all) {
tableElement .outerHTML = tableElement .outerHTML; //outHTML ie ,firefox
}
</script>
</body>
</html>