Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 input date type jQuery trigger

Tags:

html

jquery

input

I'm trying to programmatically trigger the dropdown component (the calendar bit) of an input of type date (similar to clicking the down arrow on the input field). Is this possible? I don't want to use a datepicker library.

HTML:

<input type="date" id="myDatePicker">
<button id="myButton">Click Me</button>

JavaScript/jQuery:

$('#myButton').click(function(){
    //$('#myDatePicker').click();//Doesn't do anything...
    //$('#myDatePicker').blur();//Doesn't do anything...
    //$('#myDatePicker').change();//Doesn't do anything...
    //$('#myDatePicker').focus();//Doesn't do anything...
});

http://jsfiddle.net/joepegler/mvobkjcu/8/

like image 973
Joe Austin Avatar asked Nov 22 '22 07:11

Joe Austin


1 Answers

Long story short it would appear that you can't. I used a datepicker instead.

like image 187
Joe Austin Avatar answered Jun 25 '23 02:06

Joe Austin