Execute the javascript function when the div value changes
source link: https://www.codesd.com/item/execute-the-javascript-function-when-the-div-value-changes.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Execute the javascript function when the div value changes
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:
$("#country").html('Germany').trigger('CountryChanged');
$('#country').on('CountryChanged', function(event, data) {
//contentchanged
});
Related Articles
execute a javascript function when the user selects a file
How can I execute a javascript function when an input changes?
How to trigger a JavaScript function when there are values in three input elements?
How to execute a javascript function when a page is loaded
How to execute a JavaScript function when this specific onclick event is performed?
How to execute the javascript function when the user clicks on the image
Run the javascript function when the entry is pressed - JavaScript only no Jquery
How do I run the javascript function when it reaches an anchor tag?
How can I call a javascript function when the check box is ticked
Trigger the javascript function when the facebook comment is gone
Hiding a division when selecting the selected value changes
Ng-change does not work when the selected value changes
How do I take the div value and use it in order
JQuery to update internal html when the cursor value changes
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK