没有form表单情况下敲回车键提交表单的js代码
作者:bea
<html> <head> <title></title> <script type="text/javascript"> function enterPress(e) { if (e.keyCode == 13) { login(); } } function login(){ //登录验证等 alert('login'); } </script> </head> <body>
<html>
<head>
<title></title>
<script type="text/javascript">
function enterPress(e) {
if (e.keyCode == 13) {
login();
}
}
function login(){
//登录验证等
alert('login');
}
</script>
</head>
<body>
<table id='logintable' border="1" cellpadding="0" cellspacing="0">
<tr>
<td>
Username:<input id="userName" type="text" name="userName"
style="width: 90px;" onkeydown="javascript: enterPress(event);"/>
</td>
<td>
Password:<input id="password" type="password" name="password"
style="width: 90px;" onkeydown="javascript: enterPress(event);"/>
</td>
<td>
<input id="login" type="button" value="Login" onclick="login()" />
</td>
</tr>
</table>
</body>
</html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行]
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 支持ie与FireFox的剪切板操作代码
- javaScript 简单验证代码(用户名,密码,邮箱)
- JS 连锁泡泡 v1.1
- 一个特殊的排序需求的javascript实现代码
- javascript parseInt 大改造
- 网页自动跳转代码收集
- JavaScript中Object和Function的关系小结
- 用Javascript 获取页面元素的位置的代码
- Javascript showModalDialog两个窗体之间传值
- Javascript 两个窗体之间传值实现代码
- Javascript 数组添加 shuffle 方法的实现代码
- Javascript 数组添加一个 indexOf 方法的实现代码
- jQuery 使用手册(七)
- jQuery 使用手册(六)
- jQuery 使用手册(五)
- jQuery 使用手册(四)
- jQuery 使用手册(三)
- jQuery 使用手册(二)
- jQuery 使用手册(一)