简体   繁体   中英

datepicker does not display months but days

Hello I have a problem with the datepicker. I see the days and not only the months I mean instead of having this :

日期选择器

I get this :

日期选择器

Here is my code :

 <input type="text" id="datepicker" />

and here is the js :

$("#datepicker").datepicker( {
    format: "mm-yyyy",
    viewMode: "months", 
    minViewMode: "months"
});

Could you help me please ?

Thank you very much !

Try this.

 $(document).ready(function(){ $("#datepicker-month").datepicker( { format: "mm-yyyy", viewMode: "months", minViewMode: "months" }); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script> <input type="text" id="datepicker-month" />

Hope this will help you:

$('#you-date-picker-element').datepicker({
    autoclose: true,
    minViewMode: 1,
    orientation: 'left',
    container: '.your-date-picker-container',
    format: 'M-yyyy'
}).on('changeDate', function(selected){
    startDate = new Date(selected.date.valueOf());
    startDate.setDate(startDate.getDate(new Date(selected.date.valueOf())));
    $('#your-field-name').datepicker('setStartDate', startDate);
}); 

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