You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
555 B

  1. /* eslint-disable no-unused-vars */
  2. function setInputSelection (input, startPos, endPos) {
  3. input.focus()
  4. if (typeof input.selectionStart !== 'undefined') {
  5. input.selectionStart = startPos
  6. input.selectionEnd = endPos
  7. } else if (document.selection && document.selection.createRange) {
  8. // IE branch
  9. input.select()
  10. var range = document.selection.createRange()
  11. range.collapse(true)
  12. range.moveEnd('character', endPos)
  13. range.moveStart('character', startPos)
  14. range.select()
  15. }
  16. }
  17. /* eslint-enable no-unused-vars */