Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save anilmeena/d97f3535056881bc47c98918a827f20c to your computer and use it in GitHub Desktop.

Select an option

Save anilmeena/d97f3535056881bc47c98918a827f20c to your computer and use it in GitHub Desktop.
jQuery Datepicker onSelect event get class
(function ($) {
$(document).ready(function () {
$("#calendar").datepicker({
dateFormat: 'yyyy-mm-dd',
beforeShowDay: function (date) {
return [true, 'reserved', 'this date reserved'];
},
onSelect: function (date, el) {
var day = el.selectedDay,
mon = el.selectedMonth,
year = el.selectedYear;
var el = $(el.dpDiv).find('[data-year="'+year+'"][data-month="'+mon+'"]').filter(function() {
return $(this).find('a').text().trim() == day;
});
if ( el.hasClass('reserved')){
console.log('it is reserved!');
} else {
console.log('it is not reserved');
}
}
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment