jQuery Tutorial Tutorials - jQuery :nth-last-child selector

:nth-last-child selector

The jQuery :nth-last-child selector is used to select all the elements that are the nth-child of their parent,counting from the last.

jQuery :nth-last-child selector Syntax

$(':nth-last-child(index/even/odd/equation')

difference between :nth-child(2) and :nth-last-child(2)

  • :nth-child(2) is selecting second child,counting from the first element to the last;
  • :nth-last-child(2) is selecting second child,counting from the last element to the first;

jQuery :nth-last-child selector Examples

In below example,We will hightlight third p in each matched div, counting from last child to the first

Try now

Date:2019-08-18 12:54:34 From:www.Lautturi.com author:Lautturi