Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 2
I have demonstrated 3 methods using HTML, jQuery & vanilla js
HTML:
You can get this working using type="reset" attribute on button, <input> & <button> should be inside <form> container.
<form>
<input type="date">
<button type="reset">clear</button>
</form>
jQuery:
In jQuery you can use .val() method.
by making #date value .val("") empty
<input id="date" type="date">
<button>clear</button>
<script>
$("button").on("click",function(){
$("#date").val("")
})
</script>
Vanilla js:
This is same method as jQuery only in vanilla
select date input and make it's Value to Empty value= ""
<input id="date" type="date">
<button onclick="clearDate()">clear</button>
</body>
<script>
function clearDate(){
document.getElementById("date").value = ""
}
</script>