jQuery UI datepicker:在日期选择后移动到下一个字段

时间:2021-12-31 20:36:34

I've created a web form that uses the jQuery-UI datepicker. When a date is selected, the focus on the textbox where the date is entered is lost.

我创建了一个使用jQuery-UI datepicker的Web表单。选择日期后,对输入日期的文本框的焦点将丢失。

I would like to make the focus either stay in the datepicker-enabled textbox or else move to the text element on my web form. Is this possible?

我想让焦点留在启用了datepicker的文本框中,或者移动到我的Web表单上的文本元素。这可能吗?

2 个解决方案

#1


10  

$('.selector').datepicker({
   onClose: function(dateText, inst) {
      $(this).focus();
   }
});

http://jsfiddle.net/HNeF9/

http://jsfiddle.net/HNeF9/

#2


1  

upon selecting a date, the onClose event is run... so you could put some code in there, and that could focus where you want to

选择一个日期后,运行onClose事件...所以你可以在那里放一些代码,这可以集中在你想要的地方

$('.selector').datepicker({
   onClose: function(dateText, inst) { ... }
});

#1


10  

$('.selector').datepicker({
   onClose: function(dateText, inst) {
      $(this).focus();
   }
});

http://jsfiddle.net/HNeF9/

http://jsfiddle.net/HNeF9/

#2


1  

upon selecting a date, the onClose event is run... so you could put some code in there, and that could focus where you want to

选择一个日期后,运行onClose事件...所以你可以在那里放一些代码,这可以集中在你想要的地方

$('.selector').datepicker({
   onClose: function(dateText, inst) { ... }
});