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

时间:2013-01-11 14:45:59

标签: javascript jquery javascript-events

当我拖动;从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

1 个答案:

答案 0 :(得分:0)

不确定您要找的是:

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

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