How to focus on a form input text field on page load using jQuery?

前端 未结 11 1177
天命终不由人
天命终不由人 2020-11-28 18:56

This is probably very simple, but could somebody tell me how to get the cursor blinking on a text box on page load?

11条回答
  •  無奈伤痛
    2020-11-28 19:12

    The line $('#myTextBox').focus() alone won't put the cursor in the text box, instead use:

    $('#myTextBox:text:visible:first').focus();
    

提交回复
热议问题