jQuery :nth-of-type() Seçici
Örnek
Üst öğesinin üçüncü <p> öğesi olan her <p> öğesini seçin:
$("p:nth-of-type(3)")
Tanım ve Kullanım
:nth-of-type( n ) seçicisi, üst öğelerinin belirli bir türün n'inci çocuğu olan tüm öğeleri seçer .
İpucu: :nth-child() seçicisini , türünden bağımsız olarak üst öğelerinin n'inci çocuğu olan tüm öğeleri seçmek için kullanın .
Sözdizimi
: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 |
Kendiniz Deneyin - Örnek
her <p> öğesini seçin Tüm <div> öğelerinin ikinci <p> öğesi olan her bir <p> öğesi nasıl seçilir.
Formül kullanma (an + b ) Farklı alt öğeler seçmek için formül ( an + b
nasıl kullanılır .
kullanma Farklı alt öğeleri seçmek için çift ve tek nasıl kullanılır.
arasındaki fark p:nth-child(2), p arasındaki fark :son-son-çocuk(2), nth-of-type(2) ve p:nth-of-type(2).