<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script type="text/javascript"> onload = function () { //tb代表id为u的文本框 var tb = document.getElementById("u"); //获取文本框的长度 var leng = tb.value.length; //选择起始位置 = 当前长度 tb.selectionStart = leng; } </script> </head> <body> <input type="text" id="u" value="测试看看能不能到后面" /> </body> </html>
原文:http://www.cnblogs.com/caihuashun/p/3896039.html