日期:2014-05-18  浏览次数:20426 次

敲回车,让光标移动到指定的TextBox中……
asp.net 在页面敲回车使光标自动跳到指定TextBox中并选中TextBox内容,选择内容后并且将内容变色。
  请问如何实现?给具体实例!!!谢谢!


------解决方案--------------------
$(document).bind(click,function(){
$("#txt1").focus().select();
})

------解决方案--------------------
探讨

$(document).bind(click,function(){
$("#txt1").focus().select();
})

------解决方案--------------------
探讨

引用:
$(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>