I have a problem: I have table that is updated from time to time by AJAX script. This update is called from Chrome plugin which I don’t want to change. So I’d like to add some kind of jQuery trigger that on change of table cells will call my own function.
Is it possible? I tried event onChange but it doesn’t work (it’s for input if I’m right)
Thanks in advance!
onchangeis designed for use with inputs like<select>– so wont work in this context. There are specific dom related events you can use (likeDOMSubtreeModified), but these aren’t cross-browser and have varying implementations (they may even now be deprecated):http://en.wikipedia.org/wiki/DOM_events
MutationEventsas mentioned above have seemingly been replaced byMutationObserverswhich I have not used yet myself… but sounds like it would do what you need:http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#mutation-observers
setInterval
Other than that you can fallback to a
setIntervalhandler that will listen for any change in the HTML within your target element… when it changes you fire a function.jQuery Plugin
If you want to jQueryify the above into something you can apply to any element it would easy to modify:
Obviously the above is a very simple version, it should be extended to handle adding and removing of listeners.