Jquery Child Filters

Jquery Child Filters

Child filters allow you to refine the selection by looking at the relationship that the element has with its parent elements.

Here are a few examples of how you may use visibility filters

Filter Purpose

:nth-child(index)
:nth-child(event)
:nth-child(odd)
:nth-child(equation)

Matches elements at index, even or odd increments, or who match an equation (e.g. 3n+1)
:first-child Matches elements who are the first child of their parent
:last-child Matches elements who are the last child of their parent
:only-child Matches elements who are the only child of their parent

You can actually give nth-child an equation of the form xn+m and m is option obviously. For example, you can say 2n for every second one or you can say 3n+1 and then n will start counting at 0. It will count 0, 1, 2 and so on.

Then this equation will be calculated and then that will be the index of the element that gets selected.

 

comments powered by Disqus