From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/element/queryselector/index.html | 91 +++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 files/ja/web/api/element/queryselector/index.html (limited to 'files/ja/web/api/element/queryselector') diff --git a/files/ja/web/api/element/queryselector/index.html b/files/ja/web/api/element/queryselector/index.html new file mode 100644 index 0000000000..12c10525d5 --- /dev/null +++ b/files/ja/web/api/element/queryselector/index.html @@ -0,0 +1,91 @@ +--- +title: Element.querySelector() +slug: Web/API/Element/querySelector +translation_of: Web/API/Element/querySelector +--- +
{{APIRef}}
+ +

対象要素の子孫の内、引数に指定したCSSセレクタにマッチする最初の要素を返します。

+ +

構文

+ +
element = baseElement.querySelector(selectors);
+
+ + + +

+ +

次の例では、type属性を持たないか、text/csstype属性として持つ、ドキュメントボディーの中で最初のstyle要素が返却されます。

+ +
var el = document.body.querySelector("style[type='text/css'], style:not([type])");
+
+ +

注記

+ +

マッチする要素が無い場合はnullを返します。その他の場合は、最初にマッチした要素を返します。

+ +

指定されたセレクタが不正である場合、例外「SYNTAX_ERR」がスローされます。

+ +

Throws a SYNTAX_ERR exception if the specified group of selectors is invalid.

+ +

querySelector()はWebApps API仕様で定義されました。

+ +

querySelectorに渡す文字列はCSSの文法に則る必要があります。{{domxref("document.querySelector")}}で実例を見て下さい。

+ +

ブラウザ実装状況

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
BrowserSupportNotes
Internet Explorer8CSS 2.1 selectors only (IE8)
Firefox (Gecko)3.5 (1.9.1) 
Opera10 
Chrome1 
Safari (webkit)3.2 (525.3)webk.it/16587
+ +

仕様書

+ + + +

関連情報

+ + -- cgit v1.2.3-54-g00ecf