Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@romuleald
Created August 24, 2016 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save romuleald/f1b980d5ad01b9f525e8e0244f91711a to your computer and use it in GitHub Desktop.
Save romuleald/f1b980d5ad01b9f525e8e0244f91711a to your computer and use it in GitHub Desktop.
For ES6 browser/compilator
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.
};
@romuleald
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment