document.querySelectorAll のショートカット版。 querySelectorAll は NodeListオブジェクトを返すのでそのままではmapやforEachなどの配列処理を行えない。 qsa は配列で返すためのその後の処理を書きやすい。
document.querySelectorAll
querySelectorAll
qsa
qs
// 以下はほぼ同等qsa(".hoge");document.querySelectorAll(".hoge");// さらに qsa の戻り値へは配列処理が使える。qsa(".hoge").map(elm => doSomething()).forEach(elm => doAnotherThing()); Copy
// 以下はほぼ同等qsa(".hoge");document.querySelectorAll(".hoge");// さらに qsa の戻り値へは配列処理が使える。qsa(".hoge").map(elm => doSomething()).forEach(elm => doAnotherThing());
クエリを実行するルートオブジェクト
document.querySelectorAllのショートカット版。querySelectorAllは NodeListオブジェクトを返すのでそのままではmapやforEachなどの配列処理を行えない。qsaは配列で返すためのその後の処理を書きやすい。See
qs
Example