将光标放到文本末尾

    function moveEnd(obj){ 
        obj.focus(); 
        var len = obj.value.length; 
        //IE
        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; 
        } 
    } 

 

Seleciton介绍:http://www.cnblogs.com/surahe/articles/5981847.html

posted on 2016-10-20 18:11  Surahe  阅读(191)  评论(0编辑  收藏  举报