How to change default highlighted “today” date in datepicker

前端 未结 6 2046
粉色の甜心
粉色の甜心 2020-12-19 14:26

I\'m using datepicker for selecting dates in two date fields (from date and to date).

In those, the default highlighted date is today date. I need to change the defa

6条回答
  •  醉酒成梦
    2020-12-19 15:01

    I wasn't happy with how the UI Core displays the defaultDate with that flimsy border and all. After much trial and error, I added a focus method to the second datepicker and used the setDate method.

    $('#datepicker2').datepicker().focus(function(){
       $(this).datepicker('setDate',+2);
    });
    

    This will give you the selected date with a background color based on the theme and today will also retain it's background when the datepicker opens. The only downside here is if you don't wind up selecting a date from the datepicker, you've got to go back in and clear the input field.

    Seems like a bit of a hash as I generally don't like using the focus method but I'm sticking with it.

提交回复
热议问题