Javascript 如何调用datepicker jquery 的一个js 函数onSelect 事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10845206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call a js function onSelect event of datepicker jquery?
提问by Rahul
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? 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???
我想在select中调用js函数,怎么做?我的目标是从日期选择器中获取日期选择的值并在输入字段中设置属性值。谁能帮我???
回答by Kabilan S
Here goes ur code
这是你的代码
$('.datepicker').datepicker({
dateFormat: 'dd-mm-yy',
numberOfMonths: 1,
onSelect: function(selected,evnt) {
updateAb(selected);
}
});
function updateAb(value){
$('#yourInputID').val(value);
}
回答by Juan Mendes
$( ".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
更简单地说,如果您确实希望将dateText
和inst
参数传递给updateAb
$( ".datepicker").datepicker({onSelect: updateAb});
回答by thecodeparadox
$( ".datepicker").datepicker({
onSelect: function(dateText, inst) {
updateAb(dateText, inst);
}
});
In short
简而言之
$( ".datepicker").datepicker({
onSelect: updateAb
});