本帖最后由 huge92 于 2014-04-03 13:58:40 编辑

解决方案 »

  1.   

    <html>
    <head>
         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    </head>
    <body>
    <input type="text" value="qq.com" id="input" />
         <script type="text/javascript">
         $(function(){
              $("#input").click(function(){
                  
                var obj = document.getElementById("input");
                obj.value = obj.value;
                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;
                }
              })
         })
         </script>
    </body>
    </html>