Created
October 23, 2016 10:37
-
-
Save anilmeena/d97f3535056881bc47c98918a827f20c to your computer and use it in GitHub Desktop.
jQuery Datepicker onSelect event get class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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