最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Disabling current day highlighting on Twitter Bootstrap Datepicker - Stack Overflow

programmeradmin2浏览0评论

I'm using a datepicker for Twitter Bootstrap. I need to disable the current day from being selected, which means it also should not highlight the current date.

I've passed in the parameter "todayHighlight" as false, but it's still giving the TD the "active" class even though it also has "disabled".

$("#datepicker").datepicker({
    format: 'mm-dd-yyyy',
    daysOfWeekDisabled: [0,6],
    startDate: '02-04-2013',
    endDate: '02-16-2013',
    todayHighlight: false
});

It appears to be a bug in the script. Can anyone help me out and tell me how to fix it?

Here's my fiddle that shows a working example.

I'm using a datepicker for Twitter Bootstrap. I need to disable the current day from being selected, which means it also should not highlight the current date.

I've passed in the parameter "todayHighlight" as false, but it's still giving the TD the "active" class even though it also has "disabled".

$("#datepicker").datepicker({
    format: 'mm-dd-yyyy',
    daysOfWeekDisabled: [0,6],
    startDate: '02-04-2013',
    endDate: '02-16-2013',
    todayHighlight: false
});

It appears to be a bug in the script. Can anyone help me out and tell me how to fix it?

Here's my fiddle that shows a working example.

Share Improve this question asked Feb 1, 2013 at 18:03 CofeyCofey 11.4k16 gold badges54 silver badges75 bronze badges 1
  • todayHighlight is false by default – Tomas Ramirez Sarduy Commented Feb 2, 2013 at 3:49
Add a ment  | 

2 Answers 2

Reset to default 6

Just add this to your css file to reset the .active default style, is not a good idea change the bootstrap css directly:

.datepicker table tr td.active:hover, 
.datepicker table tr td.active:hover:hover, 
.datepicker table tr td.active.disabled:hover, 
.datepicker table tr td.active.disabled:hover:hover, 
.datepicker table tr td.active:active, 
.datepicker table tr td.active:hover:active, 
.datepicker table tr td.active.disabled:active, 
.datepicker table tr td.active.disabled:hover:active, 
.datepicker table tr td.active.active, 
.datepicker table tr td.active:hover.active, 
.datepicker table tr td.active.disabled.active, 
.datepicker table tr td.active.disabled:hover.active, 
.datepicker table tr td.active.disabled, 
.datepicker table tr td.active:hover.disabled, 
.datepicker table tr td.active.disabled.disabled, 
.datepicker table tr td.active.disabled:hover.disabled, 
.datepicker table tr td.active[disabled], 
.datepicker table tr td.active:hover[disabled], 
.datepicker table tr td.active.disabled[disabled], 
.datepicker table tr td.active.disabled:hover[disabled]{
        background-image: none;
        background-color: white;
        font-weight: normal;
        color: black;
        text-shadow: none;
    }

Just add setDate to null, That's how I have solved my issue

$("#datepicker").datepicker({
    format: 'mm-dd-yyyy',
    daysOfWeekDisabled: [0,6],
    startDate: '02-04-2013',
    endDate: '02-16-2013',
    todayHighlight: false
}).datepicker("setDate",null);

Hope it helps

发布评论

评论列表(0)

  1. 暂无评论