Filter by index

Description

The following code shows how to filter by index.

Example


<html>
<head>
<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--   ww  w  . j av a 2  s .  c  om-->
    $("div").css("background", "blue").filter(function(index) {
      return index == 1;
    }).css("border", "1px solid red");
  });
</script>
<style>
div {
  border: 2px white solid;
}
</style>
</head>
<body>
  <div id="first">first</div>
  <div id="second">second</div>
  <div id="third">third</div>
  <div id="fourth">fourth</div>
  <div id="fifth">fifth</div>
  <div id="sixth">sixth</div>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities