jQuery Less than selector
Description and Syntax
$(':lt(index)')
selects all elements at an index less than n
within the matched set.
$('li:lt(2)')
selects all<li>
elements preceding the third one$('.myclass:lt(1)')
selects all elements with the classmyclass
preceding the second one
Examples
The following code selects the first two table cells.
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){<!--from w ww. j a v a 2s . c o m-->
$("td:lt(2)").css("color", "red");
});
</script>
</head>
<body>
<body>
<table>
<tr><td>First</td></tr>
<tr><td>Middle</td></tr>
<tr><td>Last</td></tr>
</table>
</body>
</html>