$(document).on(" input"," .SomeClass")适用于Chrome,但不适用于IE [英] $(document).on("input",".SomeClass") works on Chrome but not IE
问题描述
I have a span with contenteditable tag and I have a function used to detect input into it..
我有一个带有contenteditable标签的跨度,我有一个函数用于检测输入。
< span class =SomeClasscontenteditable>< / span>
$ b //函数
$(document).on(input,.SomeClass,function(){
console.log(input entered);
});
//TextArea
<span class="SomeClass" contenteditable></span>
//Function
$(document).on("input", ".SomeClass", function () {
console.log("input entered");
});
这适用于Chrome,但不适用于IE 11或更低版本。
我似乎无法在网上找到任何提及,并想知道是否有人可以告诉我如何得到这个工作或更好的方法。
This works for me on Chrome but not on the IE 11 or below. I can't seem to find any mention of it online and was wondering if anyone could give me information on how to get this working or a better approach.
Thanks
推荐答案
This is a reported bug (#794285) in IE10 and IE11: contenteditable
elements do not fire the input
event.
解决方法可以处理 input
之类的不同事件类型,例如 keypress
,粘贴
:
A workaround be to handle different event types alongside input
, such as keypress
, paste
and change
:
$(document).on("input keypress paste change", ".SomeClass", function () {
console.log("input entered");
});
这篇关于$(document).on(" input"," .SomeClass")适用于Chrome,但不适用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!