Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <body> <p>Hello World!</p> <div id="main"> <p>The DOM is very useful.</p> <p>This example demonstrates the <b>getElementsByTagName</b> method</p> </div> <script> var x=document.getElementById("main"); var y=x.getElementsByTagName("p"); document.write('First paragraph inside "main" is ' + y[0].innerHTML); </script> </body> </html>
Result:
W3Schools.com - Try it yourself