Latest web development tutorials

jQuery: nth-last-of-type () selector

jQuery selector jQuery selector

Examples

Each <p> element of its parent element belonging to selected third <p> element, a child element from the last start counting:

$("p:nth-last-of-type(3)")

try it"

Definition and Usage

: nth-last-of-type (n) selector selects all elements belonging to a particular type of parent element n th element from the last child element count.

Tip: Use : nth-last-child () selector to select all elements that belong to its parent element is not limited to the type of n th element from the last child element count.


grammar

:nth-last-of-type( n |even|odd| formula )

参数 描述
n 要匹配的每个子元素的索引。

必须是一个数字。第一个元素的索引号是 1。
even 选取每个偶数子元素。
odd 选取每个奇数子元素。
formula 规定哪个子元素需通过公式 ( an + b ) 来选取。 实例:p:nth-last-child(3n+2) 选取每个第三段,从倒数第二段开始。


Examples

Try - Example

Each <p> element to select all <div> elements in the first <p> element, a child element from the last start counting
Each <p> element How to select all <div> elements in the first <p> element, a child element from the last count.

Using equation (an + b)
How to use a formula (an + b) to select a different <p> element, a child element from the last count.

Use "even" and "odd"
How to use the even and odd to select a different sub-elements, beginning from the last child element count.

: nth-child () ,: nth -last-child () ,: nth-of-type () and: nth-of-last-type different between ()
p: nth-child (2), p: nth-last-child (2), p: nth-of-type (2) and p: between nth-of-last-type (2) are different.


jQuery selector jQuery selector