LoginSignup
1
1

More than 5 years have passed since last update.

jQueryのfindメソッド

Last updated at Posted at 2018-07-01

子孫要素を取得することができるメソッド

<div id="content">
  <h2>中見出し</h2>
  <p>本文</p>
</div>
  var element = $('#content').find('h2');
  console.log(element[0]);

以下のように出力

<h2>中見出し</h2>

childrenメソッドとの違い

childrenメソッドは一つ下の階層の要素しか取得できない。

参考

[jQuery入門】find()で子要素を取得する手法まとめ!]
(https://www.sejuku.net/blog/37474)

[jQueryでfindメソッドを使って子要素を選択する方法【初心者向け】]
(https://techacademy.jp/magazine/9477)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1