<input class="textBox" type="text" id="aaaa" name="aaaa"
size="25" maxlength="64" value="ddddddddddddddd"/>
在打开窗口时,选中文本框中的“请输入用户名”,这样用户就可以直接输入了,
onfocus= "this.select() "这样是不行的,
但我试过onload= "this.select() "又不好用,
大虾们帮帮忙
size="25" maxlength="64" value="ddddddddddddddd"/>
在打开窗口时,选中文本框中的“请输入用户名”,这样用户就可以直接输入了,
onfocus= "this.select() "这样是不行的,
但我试过onload= "this.select() "又不好用,
大虾们帮帮忙
绝对可以
window.onload=function(){
setTimeout(function(){
G('aaaa').select();
},100);
}
function selectText(){
var o=document.getElementById("aaa");
o.focus();
o.select();
}
window.onload=selectText;
</script>
<input type="text" name="aaa" id="aaa" value="hello world">
document.getElementById("aaa").focus();
</script>这样就可以了
<html>
<head>
<title>Set textbox on focus after page load</title>
<script src="../../lib/jquery/jquery-1.4.2.js"></script>
<script>
$(document).ready(function(){
$('#aaa').focus();
});
</script>
</head>
<body>
aaa: <input type="text" name="aaa" id="aaa" value="aaa"><br/>
bbb: <input type="text" name="bbb" id="bbb" value="bbb"><br/>
</body>
</html>