敲回车,让光标移动到指定的TextBox中……
asp.net 在页面敲回车使光标自动跳到指定TextBox中并选中TextBox内容,选择内容后并且将内容变色。
请问如何实现?给具体实例!!!谢谢!
[解决办法]
$(document).bind(click,function(){
$("#txt1").focus().select();
})
[解决办法]
[解决办法]
[解决办法]
window.onload = function() {
document.getElementById("txt1").focus();
document.getElementById("txt1").select();
}
[解决办法]
在window.keyup上判断event.keycode,如果是enter(13),
document.getElementById("txt1").focus();
document.getElementById("txt1").select();
//以及设置其他央视
[解决办法]
- HTML code
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript"> window.onload=function(){ document.body.onkeydown=function(e){ e=e||window.event; var keyCode = e.keyCode||e.which||e.charCode; if(keyCode==13){ document.getElementById("Text1").focus(); document.getElementById("Text1").select(); return false; } } } </script></head><body style="height:100%"> <input id="Text1" type="text" value="aaa" /> </body></html>