admin管理员组

文章数量:1289540

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.

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?

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.

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?

Share Improve this question edited Sep 26, 2011 at 22:12 Marek Sebera 40.7k37 gold badges164 silver badges249 bronze badges asked Sep 26, 2011 at 22:04 Vivian RiverVivian River 32.4k64 gold badges210 silver badges323 bronze badges
Add a ment  | 

2 Answers 2

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

http://jsfiddle/HNeF9/

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

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

本文标签: javascriptjQuery UI datepicker move to the next field after date selectStack Overflow