将选定的文本拖动到输入中不会触发“DOMNodeRemoved"”

Dragging selected text into an input does not fire "DOMNodeRemoved"

本文关键字:DOMNodeRemoved quot 文本 拖动 输入      更新时间:2023-09-26

当我拖动&从div中删除文本到输入,而不是触发DOMNodeRemoved事件。如何验证文本已被删除?

js:

$(function() {
  $('.content').on('DOMNodeRemoved', function(event) {
    console.log(event);
  });
});
html:

<h2>Div content editable</h2>
<div class="content" contenteditable="true">
  drop text to input
</div>
<h2>Input</h2>
<input class="input" type="text"/>

演示:jsbin

不确定你在找什么:

http://jsbin.com/izorij/5/edit

var cached;
$(function() {
  $('.content').on('focusout', function(event) {
    if(cached!=this.innerHTML) {
      console.log(event);
      cached = this.innerHTML;
    }
  });
});