How do you programmatically clear HTML5 date fields?

后端 未结 10 1273
我在风中等你
我在风中等你 2020-12-11 16:18

I\'m looking for a way to programmatically clear HTML5 date fields with Javascript (specifically jQuery). So far I have tried two methods which I thought obvious:

         


        
10条回答
  •  爱一瞬间的悲伤
    2020-12-11 16:35

    If you can't clear a date field, this could also depend on a browser bug. I spend some time until I found out that you cannot reset the date in Firefox if the date control is disabled. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1465979

    Without the bug, I am able to clear the date like that:

    document.getElementById("myDate").value = "";
    

提交回复
热议问题