Search code examples
jquerydatetimepicker

Jquery Datetimepicker - add clear button


How can i add a clear button to the datetimepicker addon. I was thinking of replacing the done button with a clear button.


Solution

  • Create your button in HTML with a unique ID. In jQuery write this...

    $("#yourbuttonid").click(function(){
       $("#thedattimepicker").val("");
    });
    

    On click it will clear the value of whatever element you specify in the function. You can clear more elements by just duplicating the second line of code in the function for more selectors.