$(document).on(" input"," .SomeClass")适用于Chrome,但不适用于IE [英] $(document).on("input",".SomeClass") works on Chrome but not IE

查看:94
本文介绍了$(document).on(" input"," .SomeClass")适用于Chrome,但不适用于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

推荐答案

这是:<$ 794285 / ie10-11-input-event-does-not-fire-on-div-with-contented-set> rel =nofollow c $ c> contenteditable 元素不会触发输入事件。

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");
});

JSFiddle演示

这篇关于$(document).on(&quot; input&quot;,&quot; .SomeClass&quot;)适用于Chrome,但不适用于IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆