:first (since jQuery 1.0, deprecated 3.4) selects exactly one element — the first in the matched set, in document order. It equals :eq(0) / :lt(1). Prefer $("…").first() in new code.
Remember
// Legacy (still works; deprecated 3.4)
$("tr:first");
// Recommended
$("tr").first();
// Same idea
$("tr:eq(0)");
$("tr:lt(1)");
// Not the same as :first-child (can match many)
$("li:first-child");
Build a set with a CSS selector, then keep only the first item.
Select candidates with a pure CSS selector: $("tr"), $("ul li").
Take the first: .first() (recommended) or legacy :first.
Chain actions — .text(), .addClass(), events.
Remember: one match only — not one per parent.
For per-parent firsts, use :first-child instead.
Piece
Required?
Role
Base selector
Yes
Builds the matched set (e.g. tr, li)
:first / .first()
Yes
Keep index 0 of that set
Document order
—
Matches appear in DOM order
Pseudocode
Pseudocode
set = all elements matching the left selector
(in document order)
result = set[0] if set is not empty
else empty
// .first() does the same after the set is built
// :first is a jQuery-only filter (not native CSS)
Reference
Cheat Sheet
Keep these facts handy when picking the first match.
Topic
Detail
Selector
$("elem:first") ⚠ deprecated 3.4
Method
$("elem").first() ✓ preferred
Since
jQuery 1.0
Matches
0 or 1
Equivalent
:eq(0), :lt(1)
vs :first-child
One from set vs one per parent
CSS?
No — jQuery extension
Official demo
$("tr:first")
Try it
Live Preview
Mark the first row, compare with .first() / :first-child, or count matches.
Sample: one table with three rows. :first / .first() hit one row; td:first-child hits every row’s first cell.
Row 1
A
Row 2
B
Row 3
C
Result
Ready — pick an action and click Run.
Code
jQuery Examples
Short, copy-ready snippets. Prefer .first() for new code.
:first = one from the set. :first-child = one per parent.
perf
Not native CSS
:first skips querySelectorAll. Select with CSS, then .first().
empty
Empty set stays empty
If nothing matched, .first() / :first returns an empty jQuery object.
Compatibility
Browser Support
:first has been part of jQuery since 1.0. Deprecated in 3.4 in favor of .first(). It is a jQuery extension — not a CSS selector — so native querySelectorAll cannot run it alone.
✓ Deprecated · jQuery 1.0+
jQuery :first
Works in jQuery builds that still include it, but new code should use .first() after a CSS selector.
LegacyjQuery extension
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
:firstDeprecated
Bottom line: Fine for reading old code. For new projects, always use $("sel").first().
Analysis
Performance Notes
Approach
Cost
Best for
$("tr").first()
Best
New code — CSS then method
$("tr:first")
Slower path
Legacy only
$("tr").filter(":first")
OK
Official note when filtering after CSS
Because :first is not CSS, jQuery cannot hand the whole query to the browser. Select first, then narrow with .first().
Remember
Key Takeaways
Role: keep the first element in a matched set (0 or 1).
Prefer:$("sel").first() since jQuery 3.4.
Equals::eq(0) / :lt(1) — not :first-child.
Not CSS: jQuery extension — slower than native selectors alone.
One line::first picks one element from a set — learn it for old code, write .first() in new code.
Frequently Asked Questions
:first selects exactly one element — the first in the matched set, in document order. $("tr:first") matches only the first table row. Available since jQuery 1.0; deprecated in 3.4.
Yes. Official docs state :first is equivalent to :eq(0). It can also be written as :lt(1).
Yes — deprecated in jQuery 3.4. Prefer a pure CSS selector plus .first(): $("tr").first() instead of $("tr:first").
:first returns one element from the whole matched set. :first-child can return many — one per parent.
No. :first is a jQuery extension. It does not work in native querySelectorAll and skips the native selector performance boost.
:first narrows a set built by what comes before it — e.g. $("li:first") or $("li").first(). Bare $(":first") is not a useful pattern.