I have a javascript function. I want to call this function when a div content changes .
however there is no onload() for div.
How do I invoke the function then ?
I have a javascript function. I want to call this function when a div content changes .
however there is no onload() for div.
How do I invoke the function then ?
You obtain a reference to the div, and then assign a function to the onchange event of that div.
For example:
<div id="kittens">
...
</div>
function handleKittenChange() {
alert('A kitten has changed - how cwute! *squee*');
}
var kittens = document.getElementById('kittens');
kittens.onchange = handleKittenChange;