问题
I have two jQuery Date Pickers but when I put the cursor inside each of the date-pickers, all dates that were previously selected are shown as a list.
I want to clear all those dates that were previously selected.
Any help?
回答1:
What you are looking for is called autocomplete You can learn about this attr in MDN or W3C
VIA HTML:
<input type="text" class="datepicker" id="myid" autocomplete="off">
VIA JQUERY
$('.datepicker').on('click', function(e) {
e.preventDefault();
$(this).attr("autocomplete", "off");
});
VIA JQUERY ALL DATEPICKERS (class named .datepicker)
$(".datepicker").attr("autocomplete", "off");
回答2:
This is because the browser is autocompleting the field. You can stop this behaviour simply by turning off autocomplete on the input
element:
<input id="datepicker" autocomplete="off" />
Read more about this on MDN.
回答3:
var todayDate = new Date();
$(function() {
$( "#datepicker" ).datepicker({
minDate: todayDate
});
});
来源:https://stackoverflow.com/questions/51476868/how-to-clear-history-of-datepicker-in-jquery