jQuery :last-child 选择器

jQuery :last-child 选择器

jQuery 选择器 jQuery 选择器

实例

选取属于其父元素的最后一个 <p> 的子元素:


  
    $("p:last-child")

知识兔 »

定义和用法

:last-child 选择器选取属于其父元素的最后一个子元素。

提示:请使用 :first-child 选择器来选取属于其父元素的第一个子元素。

语法

$(":last-child")
实例

知识兔 - 实例

选取所有 <div> 元素的最后一个 <p> 元素
如何选取所有 <div> 元素的最后一个 <p> 元素。

:last 和 :last-child 之间的不同
演示 :last 和 :last-child 选择器之间的不同。

:last、:last-child 和 :last-of-type 之间的不同
演示 :last、:last-child 和 :last-of-type 选择器之间的不同。

jQuery 选择器 jQuery 选择器

计算机