Using getElementsByClassName outside and without "window.onload" event - Javascript DOM Event

Javascript examples for DOM Event:onload

Description

Using getElementsByClassName outside and without "window.onload" event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
        var x=document.getElementsByClassName("myInput");
        document.write('Initial: ', x, '<br>');
        document.write('Initial Length: ', x.length, '<br>');
    /*from w w w  .  j  a  v  a 2 s .c  o  m*/
      </script> 
   </head> 
   <body> 
      <div class="myInput"></div> 
      <script type="text/javascript">
        document.write('Final: ', x, '<br>');
        document.write('Final Length: ', x.length, '<br>');
    
      </script>  
   </body>
</html>

Related Tutorials