我有以下代码:
$(document).ready(function() {
let element = $('.inputField');
element.on({
'input': function(e) {
console.log('input');
},
'blur': function(e) {
console.log('blur');
}
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input class="inputField">
<input>
<button>Click here</button>
我在我的输入
上使用了两个事件
。第一个事件是输入
。我用它来检测我的输入中是否写入了某些内容。第二个是模糊
。通过此事件,我检测输入上的焦点
是否丢失(例如使用制表符进入下一个输入)或者用户是否单击了输入外部(例如在按钮上)。现在,这在 chrome
上运行得很好。我在 internet explorer
上也需要它,但模糊不起作用。我看了这个问题:
jQuery blur() or focusout() not firing in Internet Explorer
Blur event not working in IE11 and IE10
我找不到问题的解决方案。有任何想法吗?谢谢
最佳答案
尝试使用ES5语法替代ES6。
关于javascript - JQuery 模糊事件在 IE 中未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40171211/