input获取焦点后让光标始终保持在最右边

 
function moveEnd(obj) {
    obj.focus();
    var len = obj.value.length;
    if (document.selection) {
      var sel = obj.createTextRange();
      sel.moveStart('character', len);
      sel.collapse();
      sel.select();
    } else if (typeof obj.selectionStart == 'number'
      && typeof obj.selectionEnd == 'number') {
      obj.selectionStart = obj.selectionEnd = len;
    }
  }

你可能感兴趣的:(input获取焦点后让光标始终保持在最右边)