JQuery Selector gt

From CoderLearner
Jump to: navigation, search

Description

select all elements at the index greater than the index provided.

Syntax

$('element:gt(1)')

$('span:gt(1)')
$('li:gt(1)')

Example 1

<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Select</title>
      <script 
         type="text/javascript" 
         src="/lib/jquery-1.7.2.min.js">				 
      </script>

      <script>
         $().ready(function() {
            $('span:gt(1)').css('background-color','yellow');
         });
      </script>
   </head>
   <body> 
      <span class="mark-3">John</span><br/>
      <span class="mark-4">Janny</span><br/>
      <span class="mark-5">Paul</span><br/>
      <span class="mark-5">Christ</span><br/>
   </body>
</html>

Try It