小码哥的IT人生

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 属性返回由事件完成的更改类型。

可能的值:

  1. "insertText"
  2. "insertReplacementText"
  3. "insertLineBreak"
  4. "insertParagraph"
  5. "insertOrderedList"
  6. "insertUnorderedList"
  7. "insertHorizontalRule"
  8. "insertFromYank"
  9. "insertFromDrop"
  10. "insertFromPaste"
  11. "insertTranspose"
  12. "insertCompositionText"
  13. "insertFromComposition"
  14. "insertLink"
  15. "deleteByComposition"
  16. "deleteCompositionText"
  17. "deleteWordBackward"
  18. "deleteWordForward"
  19. "deleteSoftLineBackward"
  20. "deleteSoftLineForward"
  21. "deleteEntireSoftLine"
  22. "deleteHardLineBackward"
  23. "deleteHardLineForward"
  24. "deleteByDrag"
  25. "deleteByCut"
  26. "deleteByContent"
  27. "deleteContentBackward"
  28. "deleteContentForward"
  29. "historyUndo"
  30. "historyRedo"
  31. "formatBold"
  32. "formatItalic"
  33. "formatUnderline"
  34. "formatStrikethrough"
  35. "formatSuperscript"
  36. "formatSubscript"
  37. "formatJustifyFull"
  38. "formatJustifyCenter"
  39. "formatJustifyRight"
  40. "formatJustifyLeft"
  41. "formatIndent"
  42. "formatOutdent"
  43. "formatRemove"
  44. "formatSetBlockTextDirection"
  45. "formatSetInlineTextDirection"
  46. "formatBackColor"
  47. "formatFontColor"
  48. "formatFontName"

浏览器支持

属性 Chrome IE Firefox Safari Opera
inputType 60 不支持 不支持 支持 47

语法

event.inputType

技术细节

返回值: 字符串值,指示完成的动作类型。

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024