Created
August 24, 2016 15:34
-
-
Save romuleald/f1b980d5ad01b9f525e8e0244f91711a to your computer and use it in GitHub Desktop.
For ES6 browser/compilator
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
var modifyInputValue = function ($elem, e, value, gap = 0) { | |
var target = e.target, | |
position = target.selectionStart; // Capture initial position | |
$elem.val(value); | |
target.selectionEnd = position + gap; // Set the cursor back to the initial position. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
via http://stackoverflow.com/a/29440988/1111891