<html><head><title>test</title></head><body><div id="div1"><b>aaa</b></div><table id="table1"><tr id="tr1"><td>1</td><td>2</td></tr><tr id="tr2"><td>3</td><td>4</td></tr></table></body><script type="text/javascript">var table1 = document.getElementById("table1");var tr1 = table1.rows[0];var htmlSpan = document.createElement("tr");htmlSpan.innerHTML = "<td>aaa</td><td>bbb</td>";//htmlSpan.style.height = 25;tr1.parentNode.insertBefore(htmlSpan,tr1);</script></html>为什么这段代码在IE6下无法成功。
2 回答
慕桂英4014372
TA贡献1871条经验 获得超13个赞
htmlSpan.innerHTML = "<td>aaa</td><td>bbb</td>";
主要是这在ie中不会生成规范的td,既然create了tr就在create dt吧,如下
<script type="text/javascript">
var table1 = document.getElementById("table1");
var tr1 = table1.rows[0];
var htmlSpan = document.createElement("tr");
var td1 = document.createElement("td");
var td2 = document.createElement("td");
td1.innerHTML = "aaa";
td2.innerHTML = "bbb";
htmlSpan.appendChild(td1);
htmlSpan.appendChild(td2);
//htmlSpan.style.height = 25;
tr1.parentNode.insertBefore(htmlSpan,tr1);
</script>
- 2 回答
- 0 关注
- 1200 浏览
添加回答
举报
0/150
提交
取消