日期:2014-05-16  浏览次数:20375 次

ie6/7/8 innerHTML 失效

<!DOCTYPE>
<html>
<head>
<title> new document </title>
</head>
<body>

</body>
</html>

<script type="text/javascript">
<!--
var p = document.createElement("p");
p.setAttribute("id", "box");
document.body.appendChild(p);
var box = document.getElementById("box");
box.innerHTML = "<h1>Inner Html</h1>";
//-->
</script>


innerHTML不起作用,难道要一个个节点创建,有没有比较快的方法?

------解决方案--------------------
IE8- p里面不能加入h1,你用开发工具看就知道了,p改为div

var p = document.createElement("div");