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 lastChild inside div tag.</p> <button onclick="myFunction()">Click Me</button> <p id="point"></p> <p><strong>Note</strong>: The lastChild include tags and texts.</p> <script> var x = document.getElementById("point"); var y = document.getElementsByTagName("div")[0]; function myFunction(){ x.innerHTML = y.lastChild.nodeName; } </script> </body> </html>
OUTPUT
×

Save as Private