<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.