How to detect when the text of an html element changes
I have an error message:
<span class="errorMessage">Your input sucks!</span>
and I need to determine when it will change. the validation framework I use sets the text when there is an error and removes it when it completes. I am hoping to use this by observing changes in the text property of an element with jquery. Any idea on how to do this?
Thanks!
a source to share
Handling the DOMCharacterDataModified event will be correct (and probably the only way that doesn't involve polling).
IE does not support this event, however, and some other browsers have some limitations that might make this useless for you: http://www.quirksmode.org/dom/events/#t12
So, the easiest solution would be to set up an interval timer that checks the content of your element every ~ 250ms and then triggers whatever actions you want to take.
a source to share