【发布时间】:2015-04-22 20:38:46
【问题描述】:
jQuery 的 datepicker 的默认日期是当前日期,但我需要它是我的 #start_date 输入字段中预先填充的日期。
这是我现在的位置,但它不起作用。
var start_date = $('#start_date').val();
$('.datepicker').datepicker("option", "defaultDate", start_date);
<input type="text" id="start_date" name="start_date" class="datepicker form-control col-sm-6" placeholder="Start" value="<?php (!empty($row['start_date'])?$row['start_date']:'');?>>
【问题讨论】:
-
The default date for jQuery's datepicker is the current date并非如此。假设输入字段的值采用可以解析为Date()的格式,这将用作默认值。如果不是有效的Date(),则默认为今天。 -
$row['start_date']的值是多少?
标签: jquery date datepicker default