Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>The Element Object</h1> <h2>The lastChild Property</h2> <div id="myDIV"> <p>Second child in div</p> <p>Fourth child in div</p> </div> <p>The node name of "myDIV"s last child node is.</p> <p id="demo"></p> <p>Whitespaces inside elements are considered text nodes. In this example, the first, third and fifth child of "myDIV" is a #text node.</p> <script> let text = document.getElementById("myDIV").lastChild.nodeName; document.getElementById("demo").innerHTML = text; </script> </body> </html>