Home >>jQuery Tutorial >jQuery :lt() Selector

jQuery :lt() Selector

jQuery :lt() Selector

jQuery :lt() selector in jQuery is used to selects elements with an index number less than a specified number which starts at 0.

Syntax:
$(":lt(index)")

Parameter Values

Parameter Description
index It is a Required parameter which is used to specifies which element to select.
Here is an Example of jQuery :lt() Selector:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("tr:lt(4)").css("background-color", "orange");
});
</script>
</head>
<body>
<h1>Welcome to Phptpoint !</h1>
<table border="1">
<tr>
<th>S.No</th>
<th>Country</th>
</tr>
<tr>
<td>1</td>
<td>India</td>
</tr>
<tr>
<td>2</td>
<td>Italy</td>
</tr>
<tr>
<td>3</td>
<td>France</td>
</tr>
<tr>
<td>4</td>
<td>UK</td>
</tr>
<tr>
<td>5</td>
<td>Mexico</td>
</tr>
<tr>
<td>6</td>
<td>Sweden</td>
</tr>
<tr>
<td>7</td>
<td>Germany</td>
</tr>
<tr>
<td>8</td>
<td>Canada</td>
</tr>
</table>
</body>
</html>

Output:

Welcome to Phptpoint !

S.No Country
1 India
2 Italy
3 France
4 UK
5 Mexico
6 Sweden
7 Germany
8 Canada