HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <div><h1>Heading 1</h1> <p>Paragraph 1</p> <b>Bold 1</b> </div> <p>Click the button to find the nodeType of firstChild inside div tag.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <p><strong>Note</strong>: 1 = ELEMENT_NODE; 3 = TEXT_NODE</p> <script> var x = document.getElementById("point"); var y = document.getElementsByTagName("div")[0]; function myFunction(){ x.innerHTML = y.firstChild.nodeType; } </script> </body> </html>
OUTPUT
×

Save as Private