jQueryの親>子セレクタ

❮jQueryセレクター

<div>要素の直接の子であるすべての<span>要素を選択します。

$("div > span")

定義と使用法

( "親>子")セレクターは、指定された要素の直接の子であるすべての要素を選択します。


構文

("parent > child")

Parameter Description
parent Required. Specifies the parent element to be selected
child Required. Specifies the direct child element (of the specified parent element) to be selected

自分で試してみてください-例


すべての<li>要素を選択するクラス名を持つ<ul>要素の直接の子であるすべての<li>要素を選択する方法。


❮jQueryセレクター