jQuery – :lt() Selector

The jQuery lt selector select all elements at an index less than index within the matched set. :lt 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:lt(1)").css({border:"3px #1E8CBE solid"});
});
</script>
</body>
</html>

Demo

Following example finds H6 elements less than 1st index (TD#1) and create a border around them.

Text 1
Text 2
Text 3

No comments yet.

Leave a Reply