Select a particular list item from a list - Javascript jQuery

Javascript examples for jQuery:Selector

Description

Select a particular list item from a list

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.10.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from   w ww .j  a v  a 2 s.co  m*/
$("#box li:eq(2)").text('Using eq(2)');
$("#box li:nth-child(2)").text('Using :nth-child(2)');
    });

      </script> 
 </head> 
 <body> 
  <ul id="box"> 
   <li>1</li> 
   <li>2</li> 
   <li>3</li> 
   <li>4</li> 
  </ul>  
 </body>
</html>

Related Tutorials