jQuery : nth-child () محدد

❮ محددات jQuery

مثال

حدد كل عنصر من عناصر <p> يمثل العنصر الفرعي الثالث للعنصر الأصل:

$("p:nth-child(3)")

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

يحدد محدد : nth-child ( n ) جميع العناصر التي هي العنصر n ، بغض النظر عن نوعها ، من أصلها.

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


بناء الجملة

:nth-child(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-child(3n+2) selects each 3rd paragraph, starting at the 2nd child element

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


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


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


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


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


❮ محددات jQuery