How to Set focus to first text input in a bootstrap modal after shown

后端 未结 16 1169
感情败类
感情败类 2020-12-07 15:12

I load a dynamic bootstrap modal and it contains few text inputs. The issue i face that i want the cursor to focus on the first input in this modal, and this is not happenin

16条回答
  •  猫巷女王i
    2020-12-07 16:05

    This is the simple code that will work for you best on all popups that has any input field with focusing it

    $(".modal").on('shown.bs.modal', function () {
        $(this).find("input:visible:first").focus();
    });
    

提交回复
热议问题