InputEvent inputType 属性
JavaScript基础 2022-06-08 12:05:34小码哥的IT人生shichen
InputEvent inputType 属性
实例
返回事件的输入类型:
function myFunction(event) {
var x = event.inputType;
}
完整实例:
<!DOCTYPE html>
<html>
<body>
<h1>InputEvent inputType Property</h1>
<p>The inputType property returns the type of change that was done with the event.</p>
<p>Write something, or delete something, in the text field to trigger a function.</p>
<input type="text" id="myInput" oninput="myFunction(event)">
<p>The type of action:<span id="demo"></span></p>
<p><b>注释:</b> This property is not fully supported, and can change before the final release.</p>
<script>
function myFunction(event) {
document.getElementById("demo").innerHTML = event.inputType;
}
</script>
</body>
</html>
可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html
定义和用法
inputType
属性返回由事件完成的更改类型。
可能的值:
- "insertText"
- "insertReplacementText"
- "insertLineBreak"
- "insertParagraph"
- "insertOrderedList"
- "insertUnorderedList"
- "insertHorizontalRule"
- "insertFromYank"
- "insertFromDrop"
- "insertFromPaste"
- "insertTranspose"
- "insertCompositionText"
- "insertFromComposition"
- "insertLink"
- "deleteByComposition"
- "deleteCompositionText"
- "deleteWordBackward"
- "deleteWordForward"
- "deleteSoftLineBackward"
- "deleteSoftLineForward"
- "deleteEntireSoftLine"
- "deleteHardLineBackward"
- "deleteHardLineForward"
- "deleteByDrag"
- "deleteByCut"
- "deleteByContent"
- "deleteContentBackward"
- "deleteContentForward"
- "historyUndo"
- "historyRedo"
- "formatBold"
- "formatItalic"
- "formatUnderline"
- "formatStrikethrough"
- "formatSuperscript"
- "formatSubscript"
- "formatJustifyFull"
- "formatJustifyCenter"
- "formatJustifyRight"
- "formatJustifyLeft"
- "formatIndent"
- "formatOutdent"
- "formatRemove"
- "formatSetBlockTextDirection"
- "formatSetInlineTextDirection"
- "formatBackColor"
- "formatFontColor"
- "formatFontName"
浏览器支持
属性 | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
inputType | 60 | 不支持 | 不支持 | 支持 | 47 |
语法
event.inputType
技术细节
返回值: | 字符串值,指示完成的动作类型。 |
---|