0

这是我的代码,我想获取 childNodes 并循环创建这些标签,但在 IE8 中打印 2

<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
    <div id="div"></div>
    <script type="text/javascript">
        var div = document.getElementById('div');
        var code = '<script>alert("hello");<\/script><div>dsd<\/div><script>alert("hi");<\/script>';
        div.innerHTML = code;
        console.log(div.children.length);
        console.log(div.childNodes.length)
    </script>
</body>
</html>

4

0 回答 0