dlebowski Posted February 16, 2010 Share Posted February 16, 2010 Hi. I have a div that changes it's value using AJAX. For example, <div id=name> . Is it possible for me to run a javascript function every time that value changes? So if the value of id=name is "3" and ajax changes it to "4", the value displayed in the browser has changed, but I also want it to run a function(). Is this possible? Thank you in advance. Ryan Quote Link to comment https://forums.phpfreaks.com/topic/192212-how-to-run-function-on-div-value-change/ Share on other sites More sharing options...
trq Posted February 16, 2010 Share Posted February 16, 2010 I'm not sure you can attach change events to a div element but you could give it a shot. It would be simple using jQuery. $('#name').change(function() { executefunction(); }); Quote Link to comment https://forums.phpfreaks.com/topic/192212-how-to-run-function-on-div-value-change/#findComment-1012980 Share on other sites More sharing options...
Axeia Posted February 16, 2010 Share Posted February 16, 2010 If you're not using jquery I don't think there is a way around it other than storing the old value and running a check with setInterval every x (or 0.x) seconds. (which is probably what jquery does as well if it it support it on anything beyond fileUpload, select, text (input type="text") and textareas. Quote Link to comment https://forums.phpfreaks.com/topic/192212-how-to-run-function-on-div-value-change/#findComment-1013201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.