jQuery 在 Bootstrap 的 Datepicker 上设置“开始日期”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18858892/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 22:38:00 来源:igfitidea点击:
Set 'Start Date' on Datepicker for Bootstrap
提问by
This is my datepicker field:
这是我的日期选择器字段:
<div class="form-group">
<label for="exampleInputBday">Birthday</label>
<input type="text" name="bday" class="datepicker" required>
</div>
This is my javascript:
这是我的javascript:
$(function(){
$('.datepicker').datepicker({
startDate: '-3y',
'format' : 'mm/dd/yyyy',
autoclose: true
})
})
})
When I open the datepicker, the start date is the current date! How to solve?
当我打开日期选择器时,开始日期是当前日期!怎么解决?
采纳答案by Caner Akdeniz
This should do the trick. When you are defining the date picker, you can use setDate option:
这应该可以解决问题。定义日期选择器时,可以使用 setDate 选项:
$(".datepicker").datepicker("setDate", "10/12/2013");