我在我的代碼中使用了bootstrap-datepicker。如何在JavaScript中選擇當前日期並將其顯示爲選中狀態?在Bootstrap中設置當前日期datepicker
研究後,這是我使用的代碼,但作爲選擇當天不出現:
var today = moment();
datepicker1.datepicker({
endDate: today.toDate()
});
datepicker2.datepicker({
startDate: today .toDate(),
endDate: today.toDate()
});
datepicker1.datepicker('setDate', today.toDate());
datepicker2.datepicker('setDate', today.toDate());
datepicker1.datepicker('update'); //update the bootstrap datepicker
datepicker2.datepicker('update');
也許我想念的東西,但:'開始日期:新的Date()'???但是請等待,默認情況下它會選擇當前日期,因此我真的不確定要了解您的問題? –
1.日期不在日期中輸入輸入字段 2.日期未被選中 - 日期選擇器 –