我的HTML代码
<div style="display: inline-block; font-weight: bold;">
<label for="fromDateRange">From:</label>
<div id="fromDateRange"></div>
</div>
<div style="margin-left:20px; display: inline-block; font-weight: bold;">
<label for="toDateRange">Till:</label>
<div id="toDateRange"></div>
</div>
我的javascript: -
$('#toDateRange').datepicker({
// minDate: $( "#fromDateRange" ).datepicker( "getDate" ),
changeMonth: true,
changeYear:true,
numberOfMonths: 1,
dateFormat: "yy-mm-dd",
onSelect: function( selectedDate ) {
$( "#fromDateRange" ).datepicker( "option", "maxDate", selectedDate );
}
});
$( "#fromDateRange").datepicker({
defaultDate: "-1m",
changeMonth: true,
changeYear:true,
numberOfMonths: 1,
dateFormat: "yy-mm-dd",
onSelect: function( selectedDate ) {
$( "#toDateRange" ).datepicker( "option", "minDate", selectedDate );
}
});
明确日期功能:
function clearDates() {
clear="";
$('#dateFilter').val(clear);
$("#dateFilter").trigger("change");
$('#date-range').hide();
}
一旦我清除日期选择器中的活动日期应该是默认日期。我该怎么办?
答案 0 :(得分:0)
如果我说得对,你真的想在用户使用clearDates()
时将日期设为默认日期,则必须存储已提供的信息。
为此你必须要......
Way One(LocalStorage):
//set value to browser cache
localStorage.setItem("key", "value");
//get from browser cache
localStorage.getItem("key"); //returns the setted value
//remove specific entry from browser cache
localStorage.removeItem("key"); //delete entry xy
//remove all from browser cache
localStorage.clear();
方式二:
使用cookys。