javascript - 如何解决“我们这次不执行 document.execCommand(),因为它是递归调用的”execCommand delete
问题描述
我正在使用 html5 制作表单并使用 jquery 验证字段,如果在文本字段中输入一个数字,则会立即通过 document.execCommand('delete') 将其删除,但我收到此错误在控制台开发者工具中
<input type="text" id="fieldText" placeholder="First name">
$('#fieldText').on('input', function(e){
let keyPressedNow = e.originalEvent.data;
if (keyPressedNow >= 0 && keyPressedNow <= 9) {
if (document.execCommand("delete")) {
console.log(e.originalEvent.data+' -successfully deleted')
}
}
We don't execute document.execCommand() this time, because it is called recursively.
这个错误是什么意思,我该如何解决?
解决方案
推荐阅读
- python - 如何合并 2 个字典列表,以便始终替换具有 None 值的键(如果不存在 None 值)
- html - 如何根据设备更改按钮大小?
- javascript - ReactJS - 在同一个 div 中更新组件(从列表生成)
- javascript - 检查输入表单需要两次点击才能验证
- android - 从 Firebase 子值读取的 Android Spinner 选定值
- c# - 如何通过 C# 中的事件处理程序将类的实例传回
- android - LocationManager 的 Criteria.POWER_LOW 的含义
- python - 当我尝试注销时显示找不到页面 (404)
- angular - 大型项目中的重新编译时间缓慢
- javascript - 在 Vue 中的 $router.go 之后执行函数