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