From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/document/querycommandstate/index.html | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 files/ja/web/api/document/querycommandstate/index.html (limited to 'files/ja/web/api/document/querycommandstate/index.html') diff --git a/files/ja/web/api/document/querycommandstate/index.html b/files/ja/web/api/document/querycommandstate/index.html new file mode 100644 index 0000000000..daaa234747 --- /dev/null +++ b/files/ja/web/api/document/querycommandstate/index.html @@ -0,0 +1,89 @@ +--- +title: Document.queryCommandState() +slug: Web/API/Document/queryCommandState +tags: + - API + - DOM + - Reference +translation_of: Web/API/Document/queryCommandState +--- +
{{ApiRef("DOM")}}{{obsolete_header}}
+ +

queryCommandState() メソッドは、現在の選択範囲に特定の {{domxref("Document.execCommand()")}} コマンドが適用されているかどうかを知らせます。

+ +

構文

+ +
queryCommandState(String command)
+
+ +

引数

+ +

command は {{domxref("Document.execCommand()")}} のコマンドです。

+ +

返値

+ +

queryCommandState() は {{jsxref("Boolean")}} 値、または状態が不明な場合は null を返す可能性があります。

+ +

+ +

HTML

+ +
<div contenteditable="true">Select a part of this text!</div>
+<button onclick="makeBold();">Test the state of the 'bold' command</button>
+
+ +

JavaScript

+ +
function makeBold() {
+  var state = document.queryCommandState("bold");
+  switch (state) {
+    case true:
+      alert("The bold formatting will be removed from the selected text.");
+      break;
+    case false:
+      alert("The selected text will be displayed in bold.");
+      break;
+    case null:
+      alert("The state of the 'bold' command is indeterminable.");
+      break;
+  }
+  document.execCommand('bold');
+}
+ +

結果

+ +

{{EmbedLiveSample('Example')}}

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
execCommand
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Document.queryCommandState")}}

+ +

関連情報

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