Count children, display as string - Javascript jQuery

Javascript examples for jQuery:String

Description

Count children, display as string

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from   ww w  . j a va  2  s.c o  m*/
$(document).ready( function() {
    var txt = "1/" + $("ul li").length;
    $(".counter").html( txt );
});
    });

      </script> 
 </head> 
 <body> 
  <ul> 
   <li>P</li> 
   <li>P</li> 
   <li>P</li> 
  </ul> 
  <p class="counter"></p>  
 </body>
</html>

Related Tutorials