Bootstrap Modal Focus not working

后端 未结 2 538
梦谈多话
梦谈多话 2021-02-06 00:26

while making a web I didn\'t get focus in a \"input\" into Bootstrap Modal, I tried everything and didn\'t work, modal appears but input doesn\'t get focus. I have make a \"test

2条回答
  •  礼貌的吻别
    2021-02-06 00:43

    Try this:

    $('#modal_id').modal('show').on('shown.bs.modal', function() {
        $('input_element_id').focus();
    });
    

    Or Try This:

    $('#modal_id').on('shown.bs.modal', function() {
        $('input_element_id').focus();
    });
    $('#modal_id').modal('show');
    

提交回复
热议问题