<html> <body> <p id="intro">W3Schools example</p> <div id="main"> <p id="main1">The DOM is very useful</p> <p id="main2">This example demonstrates how to use the <b>nodeValue</b> property</p> </div> <script type="text/javascript"> x=document.getElementById("intro").firstChild; document.write("First paragraph text: " + x.nodeValue); </script> </body> </html>
Your Result:
Edit the code above and click to see the result.
W3Schools.com
- Try it yourself