Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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>
11th May 2020, 1:07 AM
Sudarshan Rai
Sudarshan Rai - avatar