问题
I'm new to this: I'm playing with Bootstrap Datepicker and have got it to work with
$(document).ready(function () {
$('#datepickeron').datepicker()
});
And then a
<div id="dateoickeron"></div>
But I can't set first day or weeks like in jQuery UI. Normally I can use firstDay: 1, weekHeader: "Uge", showWeek: true like in jQuery UI and show 3 months like numberOfMonths: [3, 1], stepMonths: 3.
How do I do this for the Bootstrap Datepicker?
回答1:
Try adding weekStart . Visit here for more details about it
$(document).ready(function () {
$('#datepickeron').datepicker({
weekStart: 0 // day of the week start. 0 for Sunday - 6 for Saturday
});
});
回答2:
Some example. Hope it helps. AS usual goes inside $(document).ready(function(){});
$('#fromDate').datepicker('setStartDate', '-15d');
$('#fromDate').datepicker('setEndDate', '1d');
$('#toDate').datepicker('setStartDate', '-15d');
$('#toDate').datepicker('setEndDate', '1d');
// Initialize the dates
$('#cv-rpt-sdate').datepicker({format: 'dd-mm-yyyy',"autoclose": true});
$('#cv-rpt-edate').datepicker({format: 'dd-mm-yyyy',"autoclose": true});
$('#cv-rpt-sdate').datepicker('setEndDate', '1d');
$('#cv-rpt-edate').datepicker('setEndDate', '1d');
$('#dboard-att-date').datepicker({format: 'dd-mm-yyyy',"autoclose": true});
$('#dboard-att-date').datepicker('setStartDate', '-7d');
$('#dboard-att-date').datepicker('setEndDate', '1d');
回答3:
No need of jquery or javascript-
You can set this property in Tag itself.
property - data-date-week-start
type - integer
default - 0
description - day of the week start. 0 for Sunday - 6 for Saturday
For Example- I have set to start from Monday, then data-date-week-start="1"
<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy" data-date-week-start="1">
<input class="span2" size="16" type="text" value="12-02-2012">
<span class="add-on"><i class="icon-th"></i></span>
</div>
回答4:
Did you notice there's a typo in your 'id' element? Misspelled "datepickeron" as "dateoickeron." My apologies in advance for not simply adding this in a comment, but I haven't earned permission to do so yet.
<div id="dateoickeron"></div>
...should be:
<div id="datepickeron"></div>
来源:https://stackoverflow.com/questions/12143526/how-do-i-set-the-first-day-and-weeks-for-bootstrap-datepicker