jQuery – :gt() Selector

The jQuery gt selector select all elements at an index greater than index within the matched set. :gt selector use 0-based indexing.

Source Code

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<h6>Text 1</h6>
<h6>Text 2</h6>
<h6>Text 3</h6>
<button>Click Here</button>

  
<script>
jQuery("button").click(function () {
	jQuery("h6:gt(1)").css({border:"3px #1E8CBE solid"});
});
</script>
</body>
</html>

Demo

Following example finds H6#1 and higher and create a border around them.

Text 1
Text 2
Text 3

,

No comments yet.

Leave a Reply