jQuery > Traversing methods

.eq() - Get specific element form group in jQuery

How to find a specific element form the group of similar type of elements in jQuery?


To find a specific element from the group of similar kind of element, eq() method can be used.

 <script>
      $('p').eq(2).css('color', 'red');
  </script>

Above code snippet shall find the 2nd paragraph (“p”) from the page and apply foreground color as red.

 Views: 1201 | Post Order: 42



Write for us