The :gt(index) selector matches every element whose zero-based index in the matched set is greater thanindex. Negative indices since 1.8. jQuery extension since 1.0; deprecated in 3.4 — prefer .slice().
01
Syntax
td:gt(4)
02
> index
Strictly after
03
Official
yellow + red
04
Negative
Since 1.8
05
.slice()
index + 1
06
0-based
Like :eq()
Fundamentals
Introduction
Index filters let you target a subset of an already matched collection — skip the first few table cells, hide trailing list items, or style everything after a cutoff. The jQuery :gt(index) pseudo-class selects elements after a given position in the matched set.
jQuery has supported :gt() since version 1.0; negative indices since 1.8. Official documentation states that index-related selectors filter the set matched by what precedes them and use 0-based indexing like JavaScript arrays — unlike CSS :nth-child(n), which is 1-based.
Concept
Understanding the :gt() Selector
Think of :gt(n) as “everything after index n in this matched set”:
$("td:gt(4)") → TD #5, #6, #7, #8 — indices 5 through 8 (official demo yellow cells).
$("li:gt(0)") → all list items except the first (index 0).
:gt(1) starts at index 2 — after the second element, not including it.
Negative :gt(-2) since 1.8 — official demo colors TD #8 red.
💡
Beginner Tip
:gt(3) maps to .slice(4) when migrating — add 1 to the gt index for .slice(). Need exactly one element at an index? Use :eq(n) or .eq(n) instead.
Foundation
📝 Syntax
Official jQuery API form (since 1.0; negative since 1.8; deprecated 3.4):
Example 1 follows the official jQuery td:gt(4) and td:gt(-2) demo. Examples 2–5 cover .slice() migration, skipping the first item, contrast with :eq(), and negative indices.
📚 Official jQuery Demo
Yellow background on TD #5+; red text on TD #8 via :gt(-2).
Example 1 — Official Demo: td:gt(4) and td:gt(-2)
Official jQuery demo — cells #5–#8 yellow; cell #8 also red text.
jQuery extension — not valid in native querySelectorAll.
Index applies to the matched set from the preceding selector, not the whole document.
Compatibility
Browser Support
The :gt() pseudo-class is a jQuery extension — not standard CSS — and works in jQuery 1.0+ (negative indices 1.8+). It is deprecated in 3.4+; use .slice() instead. The method works in all browsers that support jQuery.
✓ jQuery 1.0+ · deprecated 3.4
jQuery :gt() Selector
Use $("td").slice(5) in new code — not td:gt(4) in selector strings.
100%jQuery only
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
:gt()Deprecated
Bottom line: Migrate to .slice(index + 1) — select with CSS, then filter in jQuery.
Wrap Up
Conclusion
The :gt(index) selector matches every element whose index in the matched set is greater than index — the official demo yellows TD #5 and up and reddens TD #8 via :gt(-2).
Remember 0-based indexing, the .slice(index + 1) migration path, and the difference from :eq() when you need one element vs a range.
Use :gt() in new selector strings (deprecated 3.4)
Confuse :gt(n) with :eq(n) — range vs single
Assume 1-based indexing — gt is 0-based
Expect :gt to work in querySelectorAll
Forget :gt(4) excludes index 4 itself
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :gt()
Elements after index n in the matched set.
5
Core concepts
>01
:gt(n)
Index > n
API
+102
.slice()
Migration
Tip
003
0-based
Like arrays
Rule
demo04
Official
td yellow
Demo
−05
Negative
Since 1.8
API
❓ Frequently Asked Questions
:gt(index) selects every element whose zero-based index in the matched set is greater than index. $("td:gt(4)") matches TD #5 and higher (indices 5, 6, 7, 8) in the official demo. Available since jQuery 1.0.
It selects elements after the second one — indices 2, 3, 4, and so on. Index 1 itself is not included because :gt means strictly greater than. The element at index 1 is the second item (0-based).
Since jQuery 1.8, :gt(-index) counts backwards from the last element. In the official demo, $("td:gt(-2)") turns TD #8 red — the last cell among nine TD elements (indices 0–8).
Yes — deprecated in jQuery 3.4. Official docs recommend removing :gt() from selectors and using .slice() instead: $("td").slice(5) replaces $("td:gt(4)") — add 1 to the gt index for slice.
:gt() filters the jQuery matched set by 0-based position after the preceding selector. :nth-child(n) is CSS — it picks elements that are the nth child of their parent (1-based). They use different indexing models.
:gt() always follows a selector that builds the matched set — e.g. $("li:gt(0)") not $(":gt(0)"). Index selectors narrow the set produced by what comes before them.
Did you know?
:gt(1) selects elements after the second item in the matched set (indices 2, 3, …), not the second item itself. That is why official docs say $(".myclass:gt(1)") skips the first two elements (indices 0 and 1) and starts at index 2.