function(){
if(e.keyCode == "回车")
{
var t = document.getElementById("test").createTextRange();
 
 t.moveStart("character", 0); //开头
 
 t.moveEnd("character", t.text.length); //结尾
t.select();//选中
}
}自己去完善一下代码吧

解决方案 »

  1.   

    在文本框中回车
    <input type=text onclick="doClick(this)"/>
    function doClick(obj)
    {
       obj.select();
    }
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>test</title>
    <script language="javascript" type="text/javascript">
    function keyPress(){
       if(event.keyCode==13) {
           txt1.select(); 
       }
    }
    </script></head><body>
    <input type="text" id="txt1" onkeypress="keyPress();">
    </body>
    </html>
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>test</title>
    <script language="javascript" type="text/javascript">
    function keyPress(event){
      event = event || window.event; 
       if(event.keyCode==13) {
           document.getElementsByTagName("input")['txt1'].select(); 
       }
    }
    </script></head><body>
    <input type="text" id="txt1" onkeypress="keyPress(event);">
    </body>
    </html>
    完善了下,支持FIREFOX