bootstrap datepicker show default date selected
14,462
Solution 1
After selecting the date using setDate
method, you need to update the datepicker
in order to get the selected date in datepicker
.
Before:
$('#datepicker').datepicker('setDate', new Date(2011, 2, 5));
$('#datepicker').datepicker('update'); //update the bootstrap datepicker
JSFiddle
Finally:
Solution 2
Im using bootstrap datepicker. below code worked for me:
$('#my-datepicker').datepicker('setDate', 'now');
Related videos on Youtube
Author by
user2877992
Updated on September 15, 2022Comments
-
user2877992 about 1 year
Im using bootstrap datepicker and I'm applying the set date function.
ie.,
$('.datepicker').datepicker('setDate', new Date(2011, 2, 5));
This works fine but the date specified is not getting selected.
-
sidonaldson almost 9 yearsShame there isn't a option to do this rather that using the API.