Reputation: 121
I have a jquery script to add a class to a div
jQuery('.responsive-calendar .today a').addClass('selectedDay');
This script works on the initial load of the page and adds the class. But on refreshing the page, this doesn't work and the class is not added.
So is there any function that I can use to load this script on the page refresh. I have tried adding this to the following function, but with no luck.
jQuery(window).bind("load", function() {...});
jQuery(window).load(function(){...});
jQuery(window).on('load',function() { ... });
Am I missing something here?
Upvotes: 2
Views: 1441
Reputation: 2206
Use jQuery(document).ready()
Example:
(function($) {
$(document).ready(function() {
$('.responsive-calendar .today a').addClass('selectedDay');
});
})(jQuery);
UPDATE:
For your calendar, use its onInit()
callback!
Example:
(function($) {
$(document).ready(function() {
$('.responsive-calendar').responsiveCalendar({
onInit: function() {
$('.responsive-calendar .today a').addClass('selectedDay');
}
});
});
})(jQuery);
Upvotes: 5