jQuery : nth-of-type () محدد

❮ محددات jQuery

مثال

حدد كل عنصر <p> يمثل العنصر <p> الثالث لعنصره الرئيسي:

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

التعريف والاستخدام

يحدد المحدد : nth-of-type ( n ) جميع العناصر التي هي العنصر n ، من نوع معين ، من أصلها.

تلميح: استخدم المحدد : nth-child () لتحديد جميع العناصر التي تمثل الطفل التاسع ، بغض النظر عن نوعها ، من والدها.


بناء الجملة

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

Parameter Description
n The index of each child to match.

Must be a number. The first element has the index number 1.
even Selects each even child element
odd Selects each odd child element
formula Specifies which child element(s) to be selected with a formula (an + b).
Example: p:nth-of-type(3n+2) selects each 3rd paragraph, starting at the 2nd paragraph

جربها بنفسك - مثال


. كيفية تحديد كل عنصر <p> يمثل العنصر <p> الثاني لجميع عناصر <div>.


كيفية استخدام صيغة ( أ + ب ) لتحديد عناصر فرعية مختلفة.


كيفية استخدام الفردي والزوجي لتحديد عناصر فرعية مختلفة.


الفرق بين p: nth-child (2) ، p : nth-last-child (2)، p: nth-of-type (2) and p: nth-of-last-type (2).


❮ محددات jQuery