jQuery :last-child セレクタ

❮ jQuery Selectors

その親の最後の子である全ての <p> 要素を選択する:

$("p:last-child")
Try it Yourself »

定義と用法

:last-child セレクタは、その親の最後の子である全ての要素を選択します。

チップ: 親の最初の子である全ての要素を選択するには、 :first-child セレクタを使用します。


構文

$(":last-child")

Try it Yourself - 例

全 <div> 要素の最後の <p> を選択
全 <div> 要素の最後の <p> を選択する方法。

:last と :last-child との違い
:last と :last-child セレクタとの違いを示します。

:last、:last-child、:last-of-type の間の違い
:last、:last-child、:last-of-type セレクタ間の違いを示します。


❮ jQuery Selectors