1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

要素取得判定関数まとめ

Last updated at Posted at 2024-11-27

子要素取得系

関数名 戻型 セレクタ 使えるインスタンス
getElementById Element | null ID属性値 Document , DocumentFragment
getElementsByName 生きた NodeList Name属性値 Document
getElementsByTagName 生きた HTMLCollection タグ名 Document, Element
getElementsByTagNameNS 生きた NodeList タグ名 + 名前空間URI Document, Element
getElementsByClassName 生きた HTMLCollection classList の要素値 Document, Element
evaluate XPathResult XPath Document, XPathExpression
querySelector Element | null CSS セレクタ Document, Element, DocumentFragment
querySelectorAll (生きてない) NodeList CSS セレクタ Document, Element, DocumentFragment

自身から親方向に向けた要素取得系

関数名 戻型 セレクタ 使えるインスタンス
evaluate XPathResult XPath Document, XPathExpression
closest Element | null CSS セレクタ Element

自身判定系

関数名 セレクタ 使えるインスタンス
evaluate XPath Document, XPathExpression
matches CSS セレクタ Element

感想

基本的には getElementById / querySelector / querySelectorAll / closest / matches でこと足りるかな感

evaluate はなんでもできるが IEに実装されなかったことだけが惜しい。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?