Created
April 23, 2015 09:27
-
-
Save kaid/d190c0d0f85b04bb0f0b to your computer and use it in GitHub Desktop.
move cursor to beginning of element
This file contains 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
function moveCursorTo(el) { | |
let selection = getSelection() | |
, range = document.createRange(); | |
range.setStart(el.childNodes[0], 0); | |
range.collapse(true); | |
selection.removeAllRanges(); | |
selection.addRange(range); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment