Javascript examples for DOM:Document querySelectorAll
Get CSS subclass length from main class
<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>