jQuery UI Datepicker: Highlight 7 days

亡梦爱人 提交于 2019-12-23 05:10:59

问题


I am using the jQuery UI Datepicker. It is set to inline so it is displayed to the user all the time.

The datepicker allows you to select one day however I want to be able to select a week (of seven days)

So if the user clicks for example on Wednesday 2009/10/14 it should not only highlight the 2009/10/14 but highlight all days from 2009/10/14 to 2009/10/20.

How can I realize that?


回答1:


http://jquery-datepicker.googlecode.com/issues/attachment?aid=-4481469706841499120&name=jquery.datePicker.week.js




回答2:


I know this is an old post but I just ran into the same issue and since the link is broken I'm posting my solution.

    $('#datepicker').datepicker({ 
    dateFormat: 'yy-mm-dd',
    defaultDate: '2011-05-10',
    changeMonth: true,
    changeYear: true,
    beforeShowDay: function(date){
        var selectedDate = new Date('2011-05-10');
        if (date.getFullYear() == selectedDate.getFullYear()
            && date.getMonthName() == selectedDate.getMonthName() 
            && date.getDate() >= selectedDate.getDate() 
            && date.getDate() <= selectedDate.addDays(6).getDate()
            ) {
            return [true, 'ui-datepicker-days-cell highlight', ""];
         }
        return [true, 'ui-datepicker-days-cell',""]
       }
    });


来源:https://stackoverflow.com/questions/1567338/jquery-ui-datepicker-highlight-7-days

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!