doesn't work the "for" loop
Help me plz! Why doesn't the "for" loop work? I press the button, shows the first "div", shows the length of the array, equal to two. and does not go further <!doctype html> <html> <head> </head> <body> <div class="first"> <p>div1p1</p> <p>div1p2</p> <p>div1p3</p> <button onclick="inner()">click</button> </div> <div class="first"> <p>div2p1</p> <p>div2p2</p> <p>div2p3</p> <p>div2p4</p> </div> <div class="third"> <p>div3p1</p> <p>div3p2</p> </div> <script> function inner(){ var fir=document.getElementsByClassName("first"); for(var i=0;i<fir.length;i++){ alert(fir[i].innerHTML); document.write(fir.length); } } </script> </body> </html> https://code.sololearn.com/WTlDA3Df0GtZ/?ref=app