JQuery UI Datepicker loses focus when selecting date with mouse

后端 未结 10 1552
情歌与酒
情歌与酒 2021-02-01 02:16

I am using JQuery ui with datepicker and when a user tabs on to a field, they appropriately get the calendar pop up.

  1. User tabs (via key onto field
  2. User s
10条回答
  •  被撕碎了的回忆
    2021-02-01 02:37

    Similar to Jimmy's approach, but this sets the focus to the calendar icon (assuming your calender uses an icon), I found this way more appropriate when I had multiple date pickers next to each other.

    Set the date default options so that they set focus to the icon when the calendar popup closes:

        $(".date").datepicker({
            onClose: function() {
                $(this).next('a').focus(); 
            }
        });
    

    Add a tag to the calendar icon so that it's focusable:

        $(".date").each(function() {
            $($(this).next('img')).wrap($("").attr("href","#"));
        });
    

提交回复
热议问题