简体   繁体   中英

How to call a js function onSelect event of datepicker jquery?

Please anyone help me.. I have a js function

function updateAb(param){ some manipulation }

And i am calling a datepicker jquery onselect event like..

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

I want to call the js function in select, how to do that? My objective is to get the value onselect of date from the datepicker and setting the attribute value in input field. Can anyone help me???

Here goes ur code

$('.datepicker').datepicker({
    dateFormat: 'dd-mm-yy',
    numberOfMonths: 1,
    onSelect: function(selected,evnt) {
         updateAb(selected);
    }
});

function updateAb(value){     
    $('#yourInputID').val(value);    
}
$( ".datepicker").datepicker({
    onSelect: function(dateText, inst) { 
        updateAb(dateText);
    }
});

Even more simply, if you do want the dateText and inst parameters to be passed to updateAb

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

In short

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM