:gt() Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:gt

Description

The :gt() selector selects elements whose index number is higher than a specified number.

The index numbers start at 0.

Syntax

Parameter Description
index Required. Elements with an index higher than the specified number is selected.

The following code shows how to select all <tr> elements after the 4 first:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("tr:gt(3)").css("background-color", "red");
});// w  w w  . jav a 2  s . co m
</script>
</head>
<body>

<h1>Welcome to My Web Page</h1>

<table border="1">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>A</td>
    <td>B</td>
    <td>G</td>
  </tr>
  <tr>
    <td>C</td>
    <td>C</td>
    <td>D</td>
  </tr>
  <tr>
    <td>E</td>
    <td>F</td>
    <td>G</td>
  </tr>
  <tr>
    <td>E</td>
    <td>R</td>
    <td>A</td>
  </tr>
  <tr>
    <td>I</td>
    <td>H</td>
    <td>U</td>
  </tr>
  <tr>
    <td>K</td>
    <td>P</td>
    <td>G</td>
  </tr>
  <tr>
    <td>L</td>
    <td>Y</td>
    <td>C</td>
  </tr>
  <tr>
    <td>M</td>
    <td>G</td>
    <td>I</td>
  </tr>
  <tr>
    <td>N</td>
    <td>S</td>
    <td>U</td>
  </tr>
</table>

</body>
</html>

Related Tutorials