简体   繁体   中英

JavaScript - Fire event when innerHTML or attributes change

I found a jQuery calendar that has the ability to scroll through months and I would like to fire an event every time the month changes so I can add event listeners to every td element in the table (the days are td elements). The only way that I have seen to do this is check to see when the month has changed. Is there an event that will fire whenever the innerHTML or "data-month" attribute changes? Thanks for the help. FYI, if you know an easier way, the calendar I am using is located here: https://github.com/philipehsing/jQuery.Simple-Event-Calendar/archive/master.zip

<h2 class="month" data-month="12">December 2015</h2>

there are these buttons with class btn-next and btn-prev. try to work with its click event.

if the dom element that holds the month gets updated, one of these elements had been clicked.

Just add event listeners (maybe onclick ) to the next and back buttons. Also, if the user change change the input field without using these buttons, then add an event listener ( onchange maybe) to these fields.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM