:gt(index) (since jQuery 1.0) selects elements whose zero-based index in the matched set is greater thanindex. Negative indices (from the end) are supported since 1.8.
Remember
$("td:gt(4)"); // indices 5, 6, 7, 8 …
$("li:gt(0)"); // skip the first item
$("td:gt(-2)"); // last cell (since 1.8)
// Preferred today (jQuery 3.4+):
$("td").slice(5); // same as :gt(4)
For counting from the end (1.8+), use a negative index or .slice(-n).
Style or act on the filtered set.
Piece
Required?
Role
Preceding selector
Yes
Builds the set that :gt / .slice filters
index
Yes
Zero-based; keep items with index > this value
Negative index
No
Since 1.8 — count from the end
Return value
—
jQuery set of matching elements
Pseudocode
Pseudocode
set = $(precedingSelector) // indices 0 … length-1
call set.filter(":gt(index)")
// or set.slice(index + 1)
for each element at position i in set:
if i > index:
include it
return the filtered jQuery set
Reference
Cheat Sheet
Keep these facts handy while filtering by index.
Topic
Detail
Syntax
$("sel:gt(index)")
Since
1.0 · negative index since 1.8
Deprecated
jQuery 3.4 — prefer .slice()
Migration
:gt(n) → .slice(n + 1)
Indexing
0-based (like JS arrays)
Includes index?
No — strictly greater than
vs :eq
:gt = range · :eq = one item
vs :nth-child
Set position vs parent child (1-based CSS)
Try it
Live Preview
Highlight table cells with :gt() or the modern .slice() equivalent.
TD #0
TD #1
TD #2
TD #3
TD #4
TD #5
TD #6
TD #7
TD #8
Yellow cells match the filter. :gt(4) and .slice(5) select the same cells.
Result
Ready — click Run to filter cells.
Code
jQuery Examples
Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.
Example 1 — Official td:gt(4) / td:gt(-2)
From the jQuery docs: yellow on TD #5+, red text on TD #8.
:gt() has been part of jQuery since 1.0 (negative indices since 1.8). It still works, but is deprecated since jQuery 3.4 — prefer .slice() for new code.
✓ Deprecated · jQuery 1.0+
jQuery :gt()
Works across jQuery 1.x–3.x where loaded, but avoid in new projects. Migrate to $("sel").slice(n + 1) for better performance and future compatibility.
LegacyStatus
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 3.4+
Bottom line: Fine for reading older tutorials. For production on jQuery 3.4+, use .slice() instead of :gt().
Analysis
Performance Notes
Approach
Cost
Best for
$("css").slice(n)
Best
Modern browsers + jQuery 3.4+
$("el:gt(n)")
Slower
Legacy code only — no querySelectorAll
Huge lists filtered often
Can add up
Cache the set; prefer slice once
Because :gt() is a jQuery extension, the engine cannot hand the whole query to the browser. Select with CSS, then .slice(), for the fastest path.
Remember
Key Takeaways
Role: keep items after a 0-based index — since jQuery 1.0.
Migrate::gt(n) → .slice(n + 1) (deprecated 3.4).
Strict: index n itself is not included.
Negative::gt(-2) since 1.8 · or .slice(-1) for the last item.
One line::gt(n) keeps elements after index n — prefer .slice(n + 1) in modern jQuery.
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–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.
Since jQuery 1.8, :gt(-index) counts backwards from the last element. In the official demo, $("td:gt(-2)") styles TD #8 — the last cell among nine TDs (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 — for example $("li:gt(0)"), not $(":gt(0)"). Index selectors narrow the set produced by what comes before them.