Textbox gets back focus upon timepicker close

你离开我真会死。 提交于 2019-12-24 10:38:13

问题


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.

  1. Gave them all the same css class.
  2. Do this

        $('.MyDatePickerClass').datetimepicker({
            onClose: function(dateText, inst) {
               $('.MyDatePickerClass').focus();
            }
        });
    


来源:https://stackoverflow.com/questions/8761392/textbox-gets-back-focus-upon-timepicker-close

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!