Last active
February 2, 2025 20:59
-
-
Save piyonishi/409ecbd07f7b86b7da205ad61210a275 to your computer and use it in GitHub Desktop.
How to put focus at the end of an input with React.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://coderwall.com/p/0iz_zq/how-to-put-focus-at-the-end-of-an-input-with-react-js | |
moveCaretAtEnd(e) { | |
var temp_value = e.target.value | |
e.target.value = '' | |
e.target.value = temp_value | |
} | |
render() { | |
<textarea | |
value={value} | |
autoFocus | |
onFocus={this.moveCaretAtEnd} | |
></textarea> | |
} |
Thanks, this works perfectly.
π
Prfect. mersi
Thank you very much! It saved me a lot of headache. :)
Just what I needed, many thanks π
Big help, thanks π
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nicee!!! Work for me! Thanks =)