Example 1 — Official td:gt(4) / td:gt(-2)
From the jQuery docs: yellow on TD #5+, red text on TD #8.
$("td:gt(4)").css("backgroundColor", "yellow");
$("td:gt(-2)").css("color", "red"); How It Works
- Set. All
tdcells get indices 0–8. - gt(4). Keeps only indices strictly after 4.
- gt(-2). Counts from the end; last cell matches.

