move cursor to the beginning of the input field?

前端 未结 4 938
面向向阳花
面向向阳花 2020-12-01 11:39

when you click on \'Ask question\' here in Stackoverflow you see a text \"What\'s your programming question? Be descriptive.\"

i want the same thing and all i need f

4条回答
  •  囚心锁ツ
    2020-12-01 12:39

    You can use focus() method. If I recall jQuery, its like this: $("#question_input_field_id").focus(); (If I got your question right)

    Update: Setting cursor at the beginning:

    $("#question_input_field_id").focus();
    $("#question_input_field_id").get(0).setSelectionRange(0,0);
    

提交回复
热议问题