亚洲区国产区激情区无码区,国产成人mv视频在线观看,国产A毛片AAAAAA,亚洲精品国产首次亮相在线

jQuery :nth-last-of-type() 選擇器

jQuer 選擇器

:nth-last-of-type()選擇器根據(jù)它們在一組同級兄弟中的位置(從末尾開始)選擇給定類型的所有元素。

使用:nth-last-child()選擇器,選取屬于其父元素的不限類型的第 n 個子元素的所有元素,從最后一個子元素開始計數(shù)。

語法:

$(":nth-last-of-type(number|An+B|odd|even)")

實例

從末尾算起,選擇屬于其父元素的第4個<span>元素的每個<span>元素:

$(document).ready(function(){
  $("span:nth-last-of-type(4)").css("background", "lime");
});
測試看看?/?

奇數(shù)和偶數(shù)關鍵字用于匹配索引為奇數(shù)或偶數(shù)的子元素:

$(document).ready(function(){
  $("span:nth-last-of-type(odd)").css("background", "lime");
  $("span:nth-last-of-type(even)").css("background", "aqua");
});
測試看看?/?

參數(shù)值

參數(shù)描述
number每個要匹配的子元素的索引(從1開始)
odd選擇每個奇數(shù)子元素
even選擇每個偶數(shù)子元素
An+B指定要選擇的子元素
示例:p:nth-last-of-type(3n + 2)從第二段開始選擇每個第三段

jQuer 選擇器