我想弄清楚的事件,如果有任何的方式來聽像focus
或contenteditable
屬性的HTML元素的change
事件。聽一個CONTENTEDITABLE HTML元素
我有這樣的HTML標記:
<p id="test" contenteditable >Hello World</p>
我已經試過這沒有任何成功(JSBin):
var test = document.querySelector('#test');
test.addEventListener('change', function(){
alert('content edited');
}, false);
test.addEventListener('DOMCharacterDataModified', function(){
alert('content edited');
}, false);
test.addEventListener('focus', function(){
alert('content edited');
}, false);
我不想聽到鍵盤或鼠標事件。我在W3C和MDN中找不到關於contenteditable
的任何明確文件。
是否可以在內容可編輯的HTML元素上收聽change
和focus
或其他事件?
簽出這個問題的第二個答案.http://stackoverflow.com/questions/1391278/contenteditable-change-events – rwilliams