简体   繁体   中英

By default today's date active in daterangepicker

How to remove today's date active in predefined range of date range picker. I have used http://www.daterangepicker.com/ daterangepicker as mentioned in this link

Script

$('#reportrange').daterangepicker({

        ranges: {
            'Today': [moment(), moment()],
            'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
            'Last 7 Days': [moment().subtract(6, 'days'), moment()],
            'Last 30 Days': [moment().subtract(29, 'days'), moment()],
            'This Month': [moment().startOf('month'), moment().endOf('month')],
            'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
        }        
    }, function (start, end) {
        $('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));       
    });

view
======
<div id="datepicker">

<span id="datepicker-heading">Created On</span><br />

<div id="reportrange" class="pull-right" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;">
 <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>&nbsp;
  <span>Select Date</span> <b class="caret"></b>
  </div>
  </div>

while page loading date range picker shows Select Date by default. But today is highlighted below

The "today" highlighting is built in to the daterangepicker, and does not have a native method/parameter that you can use to disable it. The easiest thing to do is just to over-ride the default CSS styling for the active date:

.daterangepicker td.active, .daterangepicker td.active:hover {
     background-color: #fff; 
     border-color: #fff; 
     color: #000; 
}

NOTE: This will prevent any highlighting from occurring when the user selects a date.

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