`

enter 事件实现登陆功能

阅读更多

不管是客户端,还是网站基本都有enter事件实现按键提交效果,其实很简单,enter的键盘码是13,只要一个onkeydown事件就可以实现.

document.onkeydown = function(e)
{
    if(!e)
    {	
    	e = window.event;
    }
    if((e.keyCode || e.which) == 13)
    {
        document.getElementById("login").click();
    }
}

 

其中登陆按钮的标签为

<td width="60" align="left"><input id ="login" class=cssButton type="button" 
               value="登录" name="submit2" onClick="return submitForm();"></td>

 


 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics