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