I have a div <div id="Country">India</div>
. I want to execute some code (say JavaScript function) whenever the div value changes. How can I listen to changes on the div value? Do i need to use Jquery for this?
|
|||||||||||||||||
|
an easy jquery solution is to use a custom event and trigger it yourself when you change the DOM:
| |||||
|
Same question: https://groups.google.com/forum/#!topic/prototype-scriptaculous/WtU5IS6gdxY jquery just make your live easy! all you can do with jquery, you can also do with normal javascript! | |||||||||||||||||||||
|
You can listen to events triggered by the MutationObserver DOM API : https://developer.mozilla.org/en/docs/Web/API/MutationObserver | |||||
|
Try this Demo, It's in Cracker0dks's link http://jsbin.com/ayiku and this is the code http://jsbin.com/ayiku/1/edit | |||
|
I have prepared a small demo for you. Its a little crude but I am sure You can improve it ;). Happy Coding :)
| |||
|
Try this within script tag:
Here "country_changed_function" is function trigger on country div innerHTML got changed. | |||
|