Javascript 在contenteditable div中输入粘贴的jquery

Javascript 在contenteditable div中输入粘贴的jquery,javascript,jquery,html,internet-explorer,Javascript,Jquery,Html,Internet Explorer,我的html页面中有一个contenteditable div作为文本区域: <div id="txt" contenteditable="true"></div> 它在chrome中运行良好,但在IE中不起作用。有人能告诉我发生了什么吗? 谢谢~~IE正在返回事件。键入作为粘贴 $('#txt').on('input paste',function(event){ if(event.type=='paste' || event.type=='input'){

我的html页面中有一个contenteditable div作为文本区域:

<div id="txt" contenteditable="true"></div>
它在chrome中运行良好,但在IE中不起作用。有人能告诉我发生了什么吗?
谢谢~~

IE正在返回
事件。键入
作为
粘贴

$('#txt').on('input paste',function(event){
   if(event.type=='paste' || event.type=='input'){
       alert("ok"); 
   }  
});
编辑。出于某种原因,我只测试了粘贴

$('#txt').on('keyup paste',function(event){
   alert("ok"); 
});

我认为这是一个IE特有的问题。另一种解决方案是使用焦点、关键帧事件和模糊事件。您可以比较新旧文本,以查看文本中是否存在更改

刚找到一条线索,给出的答案与我的答案一致;和原始SO线程的链接

$('#txt').on('focus', function() {
  before = $(this).html();
}).on('blur keyup paste', function() { 
  if (before != $(this).html()) { $(this).trigger('change'); }
});

$('#txt').on('change', function() {alert('changed')});

IE的版本是什么?IE的版本是11。IE不支持
contenteditable
元素上的
input
事件。我删除了if语句,但也没有警报对话框。
$('#txt').on('focus', function() {
  before = $(this).html();
}).on('blur keyup paste', function() { 
  if (before != $(this).html()) { $(this).trigger('change'); }
});

$('#txt').on('change', function() {alert('changed')});