开发者

How to determine when the text of an html element is changed

I have an error message like this:

<span class="errorMessage">Your input sucks!</span>

and I need to determine when it changes. the validation framework 开发者_如何学编程I'm using sets the text when there's an error and removes it when it's complete. I'm hoping to tap into that by watching for changes to the text property of the element using jquery. Any idea of how to go about doing this?

Thanks!


Handling the DOMCharacterDataModified event would be the proper (and probably the only way that does not involve polling).

However, IE does not support this event and some other browsers have some limitations which might make it useless for you: http://www.quirksmode.org/dom/events/#t12

So probably the easiest solution will be to setup an interval timer which checks your element's contents every ~250ms and then triggers whatever action you want to execute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜