twitter-bootstrap bootstrap datepicker 显示选择的默认日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20040222/
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
bootstrap datepicker show default date selected
提问by user2877992
Im using bootstrap datepicker and I'm applying the set date function.
我正在使用 bootstrap datepicker 并且我正在应用设置日期功能。
ie.,
IE。,
$('.datepicker').datepicker('setDate', new Date(2011, 2, 5));
This works fine but the date specified is not getting selected.
这工作正常,但没有选择指定的日期。
回答by Praveen
After selecting the date using setDatemethod, you need to update the datepickerin order to get the selected date in datepicker.
选择日期使用setDate方法后,您需要更新datepicker以便在datepicker.
Before:
前:


$('#datepicker').datepicker('setDate', new Date(2011, 2, 5));
$('#datepicker').datepicker('update'); //update the bootstrap datepicker
JSFiddle
JSFiddle
Finally:
最后:


回答by Ramanujam Allam
Im using bootstrap datepicker. below code worked for me:
我使用引导程序日期选择器。下面的代码对我有用:
$('#my-datepicker').datepicker('setDate', 'now');

