jQuery :nth-child() ရွေးချယ်မှု
ဥပမာ
၎င်း၏မိဘ၏တတိယမြောက်သားဖြစ်သော <p> အစိတ်အပိုင်းတစ်ခုစီကို ရွေးပါ-
$("p:nth-child(3)")
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
:nth-child( n ) ရွေးပေးသူသည် အမျိုးအစားမခွဲခြားဘဲ ၎င်းတို့၏မိဘ၏ အမျိုးအစားမခွဲခြားဘဲ nth ကလေးဖြစ် သည့် အစိတ်အပိုင်းအားလုံးကို ရွေးချယ်သည် ။
အကြံပြုချက်- :nth-of-type() ရွေးချယ်မှုအား အသုံးပြု၍ ၎င်းတို့၏မိဘ၏ အမျိုးအစားတစ်ခု၏ နံပါတ် ကလေးဖြစ်သော အစိတ်အပိုင်းအားလုံးကို ရွေးချယ်ရန် ။
အထားအသို
: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 |
ကိုယ်တိုင်စမ်းကြည့်ပါ - ဥပမာ
<div> ဒြပ်စင်အားလုံး၏ ဒုတိယကလေးဖြစ်သော <p> ဒြပ်စင်တစ်ခုစီကို ရွေးနည်း
ကို အသုံးပြု၍ မတူညီသော ကလေးဒြပ်စင်များကို ရွေးချယ်ရန်
ဖော်မြူလာ ( an + b ) ကို အသုံးပြုနည်း။
ကိုအသုံးပြုခြင်းဖြင့် မတူညီသော ကလေးဒြပ်စင်များကို ရွေးချယ်ရန် ပင်နှင့် odd ကို အသုံးပြုနည်း။
အကြား ကွာခြားချက် p:nth-child(2), p :nth-last-child(2)၊ p:nth-of-type(2) နှင့် p:nth-of-last-type(2)။