jQuery用户登录时鼠标焦点事件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Cache-Control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <title>jQuery用户登录时鼠标焦点事件</title> <script type="text/javascript" src="jquery-1.8.3.js"></script> <script type='text/javascript'> $(function(){ $("#pwd").focus(); $("#pwd").keydown(function(event){ if (event.which==13) login(); }); }); </script> </head> <body> <div style="text-align:center"> <p>用户名: <input type="text" id="usr" value='admin' style="padding-left:5px; width:150px;"></p> <p style="margin-left: 15px;">密码: <input type="password" id="pwd" style="padding-left:5px; width:150px;"/></p> <p><input style="font-size:130%;color:green" type="button" value="登录" onclick="login()" /></p> </div> </body> </html>