DocumentFragment: querySelectorAll() メソッド
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
DocumentFragment.querySelectorAll() メソッドは NodeList で、 DocumentFragment の中で指定されたセレクター群に一致する要素の一覧を(文書ノードの深さ優先前順走査 (depth-first pre-order traversal) を使用して)返します。
引数で指定されたセレクターが無効であった場合、 DOMException が SYNTAX_ERR の値で発生します。
構文
js
querySelectorAll(selectors)
引数
selectors-
文字列で、1 つ以上の CSS セレクターをカンマで区切って指定します。
返値
生きていない NodeList です。これには、指定されたセレクター群の少なくとも 1 つに一致する要素ごとに 1 つの Element オブジェクトが格納されます。一致するものがなかった場合は空の NodeList となります。
例
この例は、 DocumentFragment の中にあるすべての div 要素のうち、 "note" または "alert" クラスのついたものすべてのリストを返します。
js
const matches = documentfrag.querySelectorAll("div.note, div.alert");
仕様書
| Specification |
|---|
| DOM> # ref-for-dom-parentnode-queryselectorall①> |
ブラウザーの互換性
Loading…
関連情報
- 所属する
DocumentFragmentインターフェイス