JQuery Selector lt

From CoderLearner
Jump to: navigation, search

Description

Selector bases on the index, select elements that index less than a given index.

Syntax

$('li:lt(index)')

$('div:lt(index)')

Example 1

<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Select</title>
      <script 
         type="text/javascript" 
         src="/lib/jquery-1.7.2.min.js">				 
      </script>

      <script>
         $().ready(function() {
            $('table tr:lt(1)').css('background-color','red');
         });
      </script>
   </head>
   <body> 

      <table>
         <tr>
            <th>Group No</th>
            <th>Name</th>
            <th>Total</th>
         </tr>
         <tr>
            <td>1451</td>
            <td>Lake Group</td>
            <td>50003</td>
         </tr>
         <tr>
            <td>3451</td>
            <td>City Group</td>
            <td>5002543</td>
         </tr>
      </table>
   </body>
</html>

Try It