How to call js on function Select datepicker jquery event?

Please help me .. I have a js function

function updateAb(param){ some manipulation } 

And I call jqery datepicker onselect, for example.

 $( ".datepicker").datepicker({onSelect: function(dateText, inst) { ... }}); 

I want to call js function in select, how to do this? My goal is to get the onselect date value from the datepicker and set the attribute value in the input field. Can someone help me ???

+6
source share
3 answers

Here goes ur code

 $('.datepicker').datepicker({ dateFormat: 'dd-mm-yy', numberOfMonths: 1, onSelect: function(selected,evnt) { updateAb(selected); } }); function updateAb(value){ $('#yourInputID').val(value); } 
+25
source
 $( ".datepicker").datepicker({ onSelect: function(dateText, inst) { updateAb(dateText); } }); 

Even easier if you want to pass the dateText and inst parameters to updateAb

 $( ".datepicker").datepicker({onSelect: updateAb}); 
+5
source
 $( ".datepicker").datepicker({ onSelect: function(dateText, inst) { updateAb(dateText, inst); } }); 

In short

 $( ".datepicker").datepicker({ onSelect: updateAb }); 
+3
source

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


All Articles