Trigger event automatically on DOMCharacterChanged or change to div
so basically i have div
here contenteditable
and a button
on click
from which content changes div
! Now what I want is automatically started event
for div
after content changes.
Note. I am using jQuery version 1.8.2
DEMO
I have tried as below but no success.
<div contenteditable id="divtxt">First Text</div>
<button id="btnChange">Change</button>
Js
$('#divtxt').bind("DOMCharacterDataModified",function(){
alert('this is the event of div');
});
$('#btnChange').bind('click',function(){
$("#divtxt").text('Text Changed on click');
});
any help is appreciated!
+3
Guruprasad rao
source
to share
1 answer
Use html()
instead text()
.
$('#btnChange').bind('click',function(){
$("#divtxt").html('Changed on click');
});
+1
Zee
source
to share