jQuery :first-of-type セレクタ

❮ jQuery Selectors

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

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

定義と用法

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

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

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


構文

$(":first-of-type")

Try it Yourself - 例

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

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


❮ jQuery Selectors