控制textarea光标移到末尾

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;
    }

posted @ 2013-03-26 15:31  CatherineGao  阅读(402)  评论(0编辑  收藏  举报