diff --git a/set.js b/set.js index 7c3edb5..b774395 100644 --- a/set.js +++ b/set.js @@ -12,7 +12,10 @@ module.exports = function(input, start, end) { if (input.setSelectionRange) { input.focus(); - input.setSelectionRange(start, end); + // http://stackoverflow.com/a/11724161 + window.setTimeout(function() { + input.setSelectionRange(start, end); + },0); } else { var range = input.createTextRange(); range.collapse(true); @@ -20,4 +23,4 @@ module.exports = function(input, start, end) { range.moveStart('character', end); range.select(); } -}; \ No newline at end of file +};