jquery close datepicker when input lose focus

后端 未结 5 651
星月不相逢
星月不相逢 2020-12-06 16:41

I\'m using datepicker inside my input , my last field is the datepicker input , after validating it i want to set focus on another input inside my form , but the problem is

5条回答
  •  鱼传尺愫
    2020-12-06 17:28

    Here's a modified solution that worked for me:

    $(".hasDatepicker").each(function (index, element) {
        var context = $(this);
        context.on("blur", function (e) {
            // The setTimeout is the key here.
            setTimeout(function () {
                if (!context.is(':focus')) {
                    $(context).datepicker("hide");
                }
            }, 250);        
        });        
    });
    

提交回复
热议问题