Select in each row the last element with CSS Selector class - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Style

Description

Select in each row the last element with CSS Selector 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(){//w w  w  . j a v a 2 s.  c  om
console.log( document.querySelector( ".child:last-of-type" ) );
    }

      </script> 
   </head> 
   <body> 
      <div class="parent"> 
         <div class="child">
             1 
         </div> 
         <div class="child">
             2 
         </div> 
         <div class="child">
             3 
         </div> 
      </div>  
   </body>
</html>

Related Tutorials