NazariyM
2/13/2020 - 5:06 PM

placeCursorToEnd set cursor to end

placeCursorToEnd() {
      function addEvent(elem, event, fn) {
         if (elem.addEventListener) {
            elem.addEventListener(event, fn, false)
         } else {
            elem.attachEvent('on' + event, function() {
               return fn.call(elem, window.event)
            })
         }
      }

      addEvent(this.textArea, 'focus', function() {
         const that = this
         setTimeout(function() {
            that.selectionStart = that.selectionEnd = 10000
         }, 0)
      })
   }
const setCursorToTextEnd = () => {
         const initialVal = input.value

         input.value = initialVal + ' '
         input.value = initialVal
      }

      input.focus()
      setCursorToTextEnd()