jQuery :gt() Selector

The jQuery :gt() Selector select the elements greater than the specified index value. It applies the jquery to all the elements beyond the mentioned index.

The elements in group starts from index 0. If you specify the index value as 1, the selector selects the elements at index 2, 3,… The jQuery applies the effect(like adding color) to the all the selected elements.

Syntax
$(“:gt(n)”)

The above syntax requires a single value as a index value to select the elements. If there are 5 list elements and you specify the index value as 1. The selector selects the elements 2, 3 and 4.

If you want to learn more with live examples, you can check the examples given below.

Examples of jQuery :gt() Selector

There are two examples you can learn to select the elements. The list of examples are given below to which you can click to reach the required one.

If you don’t want to click the links given above, you can also scroll down to check these examples below. Let’s start the example to select the rows of table.

Use jQuery :gt() Selector to Select Table Row Greater Than Index 1

There are three rows in the table given below. A table is a group element whose items starts from index 0. The below examples select the table rows at index greater than 1.

Example

Test it Live

Output

The first row starts from index 0.

Sr. No. Cricketer Name Wicket
1 Sachin Tendulkar 233*
2 Mahela Jaywadena 186
3 Kumar Sangakkara 124*

The above examples contains the table and the button. You have to click the button given above to select the table rows using jQuery :gt() Selector. It select the rows at an index 2 and 3 and applies the green color to the text content.

Select List Element Greater Than Index 1

In addition to selecting the table rows, you can also select the element of list. It select all the list item greater than the specified index. A list is also contains the group element whose items starts from index 0.

The below example select all the list element whose index is greater than 1.

Example

Test it Live

Output

The first list item starts from index 0.

  • Welcome to our website Tutorialdeep.
  • Learn jQuery with Live Examples.
  • Download Codes to quickstart.
  • You can learn web development also.
  • Create your own website today.

The above example contains the list elements and the button. You have to click the button to select the element greater than index 1. It applies the green color to the text of list item after selection.