How to Set Focus on Input Field using JQuery

前端 未结 3 1987
我寻月下人不归
我寻月下人不归 2020-12-15 02:34

Given the following HTML structure:


      
      
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 02:50

    If the input happens to be in a bootstrap modal dialog, the answer is different. Copying from How to Set focus to first text input in a bootstrap modal after shown this is what is required:

    $('#myModal').on('shown.bs.modal', function () {
      $('#textareaID').focus();
    })  
    

提交回复
热议问题