简体   繁体   中英

How can I get the element of the current day selected in the calendar of Jquery UI?

I am trying to get the component of the selected element in the Jquery UI calendar, but with the datepicker - onselect, it selects the day that is previously marked and not the one that I am selecting. this is my code.

$('#eventCalendar').datepicker({
            dateFormat: 'yy-mm-dd',
            //dateFormat: 'd M yy',
            inline: true,
            minDate: 0,
            //minDate: '10-01-01',
            //minDate: '1 Jan 2010',
            onSelect: function (date) {
                printVcInfo(date);
                console.log("hello" + $(".ui-state-active").first().text());
            }
        });

The console shows the previous day that was selected and any action performed is done on the previous day. Some help.

Try with the change date event. On select, the css class, has not been applied yet.

$('#eventCalendar').datepicker({
            dateFormat: 'yy-mm-dd',
            //dateFormat: 'd M yy',
            inline: true,
            minDate: 0,
            //minDate: '10-01-01',
            //minDate: '1 Jan 2010'
       }}.bind('dateSelected', function(e, selectedDate, $td) {
        Console.log(selectedDate);
    });

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