`

将光标移动到input框中的文本结尾

    博客分类:
  • html
 
阅读更多

 

  focus_lasts是将光标移动到input框中的文本结尾

 

<body   onload= 'document.getElementById( "username ").focus() '> 
<input   type= "text "   value= "Ladygaga "  name= "username "   id= "username "   onfocus= "focus_last(this) "> 
<script   language= "javascript "> 
    <!-- 
        function   focus_last(obj){ 
            var   text   =   obj.createTextRange(); 
            text.collapse(false); 
            text.select(); 
        } 
    //--> 
</script> 
</body>  
 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics