简体   繁体   English

如何调用datepicker jQuery的js函数onSelect事件?

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

Please anyone help me.. I have a js function 请任何人帮助我..我有一个js函数

function updateAb(param){ some manipulation }

And i am calling a datepicker jquery onselect event like.. 而且我正在调用datepicker jQuery onselect事件,例如。

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

I want to call the js function in select, how to do that? 我想在select中调用js函数,该怎么做? My objective is to get the value onselect of date from the datepicker and setting the attribute value in input field. 我的目标是从datepicker获取日期选择值,然后在输入字段中设置属性值。 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 更简单地说,如果您确实希望将dateTextinst参数传递给updateAb

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

In short 简而言之

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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