From jQuery JavaScript Library
« Back to Selectors
:first
Matches the first selected element.
While this matches only a single element,
:first-child matches more than one: One for each parent.
Examples:| Name | Type |
Finds the first table row.
$("tr:first").css("font-style", "italic");
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("tr:first").css("font-style", "italic");
});
</script>
<style>
td { color:blue; font-weight:bold; }
</style>
</head>
<body>
<table>
<tr><td>Row 1</td></tr>
<tr><td>Row 2</td></tr>
<tr><td>Row 3</td></tr>
</table>
</body>
</html>