How to clear history of DatePicker in jQuery

て烟熏妆下的殇ゞ 提交于 2019-12-25 03:12:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!