Last active
June 10, 2021 14:47
-
-
Save wesinator/68f6318ecb82909661b88852e0e359d5 to your computer and use it in GitHub Desktop.
jquery way of getting cursor current position (`selectionStart`), without hardcoding element ID. https://www.geeksforgeeks.org/how-to-insert-text-into-the-textarea-at-the-current-cursor-position/
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://www.geeksforgeeks.org/how-to-insert-text-into-the-textarea-at-the-current-cursor-position/ | |
https://stackoverflow.com/questions/4069982/document-getelementbyid-vs-jquery | |
*/ | |
$(e.selector)[0].selectionStart | |
// use selectionEnd to get delta of selected text | |
$(e.selector)[0].selectionEnd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment