js dom添加回车事件

时间:2021-12-28 09:28:29
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>login</title>
<link rel="stylesheet" type="text/css" href="/static/admin/css/normalize.css"/>
<link rel="stylesheet" type="text/css" href="/static/admin/css/demo.css"/>
<!--必要样式-->
<link rel="stylesheet" type="text/css" href="/static/admin/css/component.css"/>
<!--[if IE]>
<script src="js/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container demo-1">
<div class="content">
<div id="large-header" class="large-header">
<canvas id="demo-canvas"></canvas>
<div class="logo_box">
<h3>欢迎你</h3>
<form action="#" name="f" method="post">
<div class="input_outer">
<span class="u_user"></span>
<input name="logname" class="text" style="color: #FFFFFF !important" type="text"
placeholder="请输入账户">
</div>
<div class="input_outer">
<span class="us_uer"></span>
<input name="logpass" class="text"
style="color: #FFFFFF !important; position:absolute; z-index:100;" value=""
type="password" placeholder="请输入密码">
</div>
<!--<div class="mb2" >-->
<!--<a class="act-but submit" href="javascript:;" style="color: #FFFFFF" >-->
<!--<input type="button" onclick="SignIn();" value="登录"/>-->
<!--</a>-->
<!--</div>-->
<div class="mb2">
<a class="act-but submit SignIn" href="javascript:;" style="color: #FFFFFF" onclick="SignIn();" >登录
<!--<input type="button" value="登录">-->
</a>
</div>
</form>
</div>
</div>
</div>
</div><!-- /container -->
<script src="/static/admin/js/TweenLite.min.js"></script>
<script src="/static/admin/js/EasePack.min.js"></script>
<script src="/static/admin/js/rAF.js"></script>
<script src="/static/admin/js/demo-1.js"></script>
<div style="text-align:center;"> </div>
<script type="text/javascript" src="/static/admin/js/jquery-1.10.2.js"></script>
<!--<script type="text/javascript" src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>-->
<script type="text/javascript"> function SignIn(){
var user_name = $("input[name='logname']").val();
var pass_word = $("input[name='logpass']").val();
var form = {};
form["k1"] = "v1";
form["UserName"] = user_name;
form["PassWord"] = pass_word;
console.log(form)
$.ajax({
url: "/signin",
type: 'post',
data: form,
success: function(arg){
var my_data = JSON.parse(arg);
if (my_data["statuscode"]==){
window.location.href='/admin.html';
}else{
alert("未登录或账户密码不正确!")
}; }
})
}; document.onkeydown = function (event) {
var e = event || window.event;
if (e && e.keyCode == ) { //回车键的键值为13
<!--$("#login").click(); //调用登录按钮的登录事件-->
SignIn();
}
}; </script>
</body>
</html>