Get CSS subclass length from main class - Javascript DOM

Javascript examples for DOM:Document querySelectorAll

Description

Get CSS subclass length from main class

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//from w  ww .  j a v  a 2s  . co  m
console.log(document.querySelectorAll(".select.visible .item.x").length)
    }

      </script> 
   </head> 
   <body> 
      <div class="second select visible"> 
         <div class="item x">
            text 1
         </div> 
         <div class="item x">
            text 2
         </div> 
         <div class="item x">
            text 2
         </div> 
      </div>  
   </body>
</html>

Related Tutorials