I am using the datepicker in jQueryUI and need to have the inline datepicker. The documentation says just configure a div with .datepicker rather than an input tag.
However, I can't find out how to assign a date for the picker to display by default. You can have a "value"开发者_如何学C for the input but what do you do with a div???
Use the defaultDate
option to specify the date.
<script>
$(function() {
$( "#datepicker" ).datepicker({
defaultDate: +7 // next week
});
});
</script>
Date: <div id="datepicker"></div>
The documentation of the defaultDate
option says:
Specify either an actual date via a Date object or as a string in the current dateFormat, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today.
So, you want to make sure the data.resFullDate
is the same as dateFormat
, e.g.
$( "#datepicker" ).datepicker({
defaultDate: data.resFullDate, // e.g. 10-03-28
dateFormat: 'yy-mm-dd'
});
精彩评论