From 65ccc980205f68315002478f10a20c1f1c183882 Mon Sep 17 00:00:00 2001 From: allo Date: Thu, 3 Mar 2022 13:09:47 +0800 Subject: mv to .md for Web/API/InputEvent/inputType --- .../zh-cn/web/api/inputevent/inputtype/index.html | 80 ---------------------- files/zh-cn/web/api/inputevent/inputtype/index.md | 80 ++++++++++++++++++++++ 2 files changed, 80 insertions(+), 80 deletions(-) delete mode 100644 files/zh-cn/web/api/inputevent/inputtype/index.html create mode 100644 files/zh-cn/web/api/inputevent/inputtype/index.md diff --git a/files/zh-cn/web/api/inputevent/inputtype/index.html b/files/zh-cn/web/api/inputevent/inputtype/index.html deleted file mode 100644 index 5925b3ffba..0000000000 --- a/files/zh-cn/web/api/inputevent/inputtype/index.html +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: InputEvent.inputType -slug: Web/API/InputEvent/inputType -tags: - - API - - DOM Events - - InputEvent - - inputType -translation_of: Web/API/InputEvent/inputType ---- -
{{APIRef("DOM Events")}}
- -

{{domxref("InputEvent")}} 接口中的只读属性 inputType 返回对可编辑内容所做更改的类型。可能的更改包括插入、删除和格式化文本。

- -

语法

- -
var string = inputEvent.inputType;
- -

返回值

- -

一个 {{domxref("DOMString")}} 对象,包含所做输入的类型。有许多可能的值,例如insertTextdeleteContentBackwardinsertFromPasteformatBold。有关可用输入类型的完整列表,请参阅 Input Events Level 1 规范的属性部分

- -

示例

- -

此实例记录 input events 的 inputType,在一个可编辑的 {{htmlElement("div")}} 中。

- -

HTML

- -
<p id="log">Input type: </p>
-<div contenteditable="true" style="margin: 20px;padding: 20px;border:2px dashed red;">
-  <p>Some sample text. Try inserting line breaks, or deleting text in different ways, or pasting different content in.</p>
-  <hr>
-  <ul>
-    <li>A sample</li>
-    <li>bulleted</li>
-    <li>list.</li>
-  </ul>
-  <p>Another paragraph.</p>
-</div>
- -

JavaScript

- -
const log = document.getElementById('log');
-const editable = document.querySelector('div[contenteditable]');
-editable.addEventListener('input', logInputType);
-
-function logInputType(event) {
-  log.textContent = `Input type: ${event.inputType}`;
-}
- -

尝试编辑 <div> 中的文本,并看看发生了什么事。

- -

{{EmbedLiveSample("Examples", '100%', 500)}}

- -
-

注:有关更详细的示例,请参见 Masayuki Nakano的InputEvent测试套件

-
- -

规范

- - - - - - - - - - - - - - -
规范状态备注
{{SpecName('UI Events','#dom-inputevent-inputtype','inputType')}}{{Spec2('UI Events')}}
- -

浏览器兼容性

- -
-

{{Compat("api.InputEvent.inputType")}}

-
diff --git a/files/zh-cn/web/api/inputevent/inputtype/index.md b/files/zh-cn/web/api/inputevent/inputtype/index.md new file mode 100644 index 0000000000..5925b3ffba --- /dev/null +++ b/files/zh-cn/web/api/inputevent/inputtype/index.md @@ -0,0 +1,80 @@ +--- +title: InputEvent.inputType +slug: Web/API/InputEvent/inputType +tags: + - API + - DOM Events + - InputEvent + - inputType +translation_of: Web/API/InputEvent/inputType +--- +
{{APIRef("DOM Events")}}
+ +

{{domxref("InputEvent")}} 接口中的只读属性 inputType 返回对可编辑内容所做更改的类型。可能的更改包括插入、删除和格式化文本。

+ +

语法

+ +
var string = inputEvent.inputType;
+ +

返回值

+ +

一个 {{domxref("DOMString")}} 对象,包含所做输入的类型。有许多可能的值,例如insertTextdeleteContentBackwardinsertFromPasteformatBold。有关可用输入类型的完整列表,请参阅 Input Events Level 1 规范的属性部分

+ +

示例

+ +

此实例记录 input events 的 inputType,在一个可编辑的 {{htmlElement("div")}} 中。

+ +

HTML

+ +
<p id="log">Input type: </p>
+<div contenteditable="true" style="margin: 20px;padding: 20px;border:2px dashed red;">
+  <p>Some sample text. Try inserting line breaks, or deleting text in different ways, or pasting different content in.</p>
+  <hr>
+  <ul>
+    <li>A sample</li>
+    <li>bulleted</li>
+    <li>list.</li>
+  </ul>
+  <p>Another paragraph.</p>
+</div>
+ +

JavaScript

+ +
const log = document.getElementById('log');
+const editable = document.querySelector('div[contenteditable]');
+editable.addEventListener('input', logInputType);
+
+function logInputType(event) {
+  log.textContent = `Input type: ${event.inputType}`;
+}
+ +

尝试编辑 <div> 中的文本,并看看发生了什么事。

+ +

{{EmbedLiveSample("Examples", '100%', 500)}}

+ +
+

注:有关更详细的示例,请参见 Masayuki Nakano的InputEvent测试套件

+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('UI Events','#dom-inputevent-inputtype','inputType')}}{{Spec2('UI Events')}}
+ +

浏览器兼容性

+ +
+

{{Compat("api.InputEvent.inputType")}}

+
-- cgit v1.2.3-54-g00ecf