HTML5 input date type jQuery trigger

I am trying to programmatically call a component of the drop-down list (calendar bit) of entering a type date (similar to clicking the down arrow in the input field). Is it possible? I do not want to use the 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/

+5
source share
3 answers

In short, you cannot. Instead, I used a dumper.

+4
source

Check it out (achieved this with the plugin)

http://jsfiddle.net/pandiyancool/v6zpbmao/

  $(document).ready(function() { $("#myDatePicker").datepicker({ showOn: 'button', buttonText: 'Click me', dateFormat: 'dd/mm/yy', constrainInput: true }); $(".ui-datepicker-trigger").mouseover(function() { $(this).css('cursor', 'pointer'); }); }); 
-1
source

Try

 $('#myDatePicker').focus(); 

Gotta call him.

-3
source

Source: https://habr.com/ru/post/1208143/


All Articles