jQuery键盘事件
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>键盘事件</title>
- <style type="text/CSS">
- fieldset {
- width: 300px;
- }
- dt,dd{
- display: inline;
- }
- </style>
- <script src1="js/jquery-1.8.3.js" type="text/javascript"></script>
- <script language="JavaScript">
- $(document).ready(function () {
- $("[type=password]").keyup(function () {
- $("#message").append("keyup");
- });
- $("[type=password]").keydown(function () {
- $("#message").append("keydown");
- });
- $("[type=password]").keypress(function () {
- $("#message").append("keypress");
- });
- });
- </script>
- </head>
- <body>
- <fieldset>
- <legend>会员登录</legend>
- <dl>
- <dt>用户名</dt>
- <dd>
- <input id="userName" type="text" />
- </dd>
- </dl>
- <dl>
- <dt>密码</dt>
- <dd>
- <input id="password" type="password" />
- </dd>
- </dl>
- <dl>
- <dt></dt>
- <dd>
- <input type="submit" value="登录" />
- </dd>
- </dl>
- <span id="message"></span>
- </fieldset>
- </body>
- </html>
来源: https://www.oschina.net/code/snippet_2887409_58703