jQuery :last-of-type セレクタ

❮ jQuery Selectors

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

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

定義と用法

:last-of-type セレクタは、その親における特定のタイプの最後の子である全ての要素を選択します。

チップ: これは、:nnth-last-of-type(1) に同じです。

チップ: その親における特定のタイプの最初の子である全ての要素を選択するには、 :first-of-type セレクタを使用します。


構文

$(":last-of-type")

Try it Yourself - 例

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

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


❮ jQuery Selectors