Home >Web Front-end >HTML Tutorial >About nextSibling_html/css_WEB-ITnose in IE

About nextSibling_html/css_WEB-ITnose in IE

WBOY
WBOYOriginal
2016-06-24 11:43:151340browse

    <script>        var shq = {}        shq.cmenu = function (e) {            var e = window.event ? window.event.srcElement : e.target;            if (/a/i.test(e.tagName)) {                alert(e.parentNode.nextSibling.nodeType); // 3  text                e.parentNode.nextSibling.innerHTML = e.innerHTML;                e.blur();            }        }    </script>    <div id="div1" onclick="shq.cmenu(event)">        <a href="#">特色</a>    </div>    <div id="div2"></div>

System environment: win8, ie11

Problem: nextSibling obtains the next node at the same level as the current node, but failed.

Process description: When clicking [Features], the innerHtml of div2 did not become [Features]
During debugging, it was found that e.parentNode.nextSibling is not the next div but #text, and nodetype is equal to 3.

Personal conclusion: I don’t know if it’s right or not, but this is the result now.

div1.nextSibling.nextSibling is div2.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn