access the value of HTMLCollection - Javascript DOM

Javascript examples for DOM:Element getElementsByClassName

Description

access the value of HTMLCollection

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
   </head> 
   <body> 
      <div class="review"></div> 
      <div class="review"></div> 
      <div class="review"></div> 
      <div class="review"></div> 
      <div class="review"></div>  
      <script>
    var eles = document.getElementsByClassName('review');
    console.log(eles);
    console.log(eles.length);
    console.log(eles[0]);
    console.log(eles[1]);
    console.log(eles[2]);
        /*from   ww w.  ja v a2s . com*/
      </script> 
   </body>
</html>

Related Tutorials