HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <div>Div 1</div> <h1>Heading 1</h1> <p>Paragraph 1</p> <p>Click the button to find the nextSibling of div tag.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <script> var x = document.getElementById("point"); var y = document.getElementsByTagName("div")[0]; function myFunction(){ //Try to replace "nextSibling" by "nextSibling.nextSibling" x.innerHTML = y.nextSibling.nodeName; } </script> <p><strong>Note</strong>: The nextSibling include tags and texts.</p> </body> </html>
OUTPUT
×

Save as Private