jquery 将所选文本拖到输入中不会触发“DOMNodeRemoved”

wbgh16ku  于 2022-11-03  发布在  jQuery
关注(0)|答案(1)|浏览(110)

当我将文本从div拖放到input时,没有触发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

2ekbmq32

2ekbmq321#

不确定是你要找的:
http://jsbin.com/izorij/5/edit

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

相关问题