问题
I'm using the timepicker plugin for jquery.
Once users selected a date+time and click on the "Done" button, which basically just closes the dialog, I want the textbox where datetime is set to gain back focus (the current behavior of the plugin is to blur out focus).
This is because on this page I have a set of textboxes and their tab orders are set sequentially. I need the datetime textbox to gain back focus to continue the tab order. otherwise the tab order will restart from the first text input which is inconvenient for the user.
回答1:
Description
Assuming i understand your question, you can set the focus to your textbox in the onClose
event. Please provide more information if this is not the right answer. html
or better a jsFiddle
would be great.
Sample
$('#MyDatepicker').datetimepicker({
onClose: function(dateText, inst) {
$('#MyDatepicker').focus();
}
});
More Information
- jQuery.focus()
Update
If you have several datePickers you can do this.
- Gave them all the same css class.
Do this
$('.MyDatePickerClass').datetimepicker({ onClose: function(dateText, inst) { $('.MyDatePickerClass').focus(); } });
来源:https://stackoverflow.com/questions/8761392/textbox-gets-back-focus-upon-timepicker-close