put cursor at end of text input's value

后端 未结 5 2047
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 07:37

So, currently I have a text-input-field with a value that is also autofocused.

On page load, the value is selected / highlighted. Is there a way I can put the cursor at

5条回答
  •  日久生厌
    2021-02-02 07:58

    Use this, its nice work for me...

    
    

    OR add this line to your input element

    onfocus="this.setSelectionRange(this.value.length,this.value.length);"
    

提交回复
热议问题