jQuery :first-childセレクター

jQuery 选择器jQuery セレクター

例

親要素内で最初の <p> である要素を選択します:

$("p:first-child")

試してみる »

定義と使い方

:first-child セレクターは、親要素の最初の子要素を選択します。

ヒント:セレクターを使用して:last-child親要素の最後の子要素を選択してください。


構文

$(":first-child")


实例

試してみる - 例

すべての <div> 要素の最初の <p> 要素を選択します
すべての <div> 要素の最初の <p> 要素を選択する方法。

:first と :first-child の違い
:first と :first-child セレクターの違いをデモします。

:first、:first-child、:first-of-type の違い
:first、:first-child、:first-of-type セレクターの違いをデモします。


jQuery 选择器jQuery セレクター

その他の拡張