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>nodeList length</b> property</p> </div> <script type="text/javascript"> x=document.getElementsByTagName("p"); for (i=0;i<x.length;i++) { document.write(x[i].innerHTML); document.write("<br />"); } </script> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself