Tryit Editor v1.4

<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>getElementsByTagName</b> method</p> </div> <script type="text/javascript"> x=document.getElementById("main").getElementsByTagName("p"); document.write("First paragraph inside the main div: " + x[0].innerHTML); </script> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself