0

当我将文本从 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

4

1 回答 1

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;
    }
  });
});
于 2013-01-11T14:54:52.353 回答