zoukankan      html  css  js  c++  java
  • 键盘事件(在输入框中输入内容后按回车键)

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" lang="en">

        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <title>登录直接按回车的效果</title>
            <script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
            <script type="text/javascript">
                $(function() {
                    $("input[type='text']:eq(0)").keyup(
                        function() {
                            if(event.keyCode == 13) {
                                $("input[type='password']:eq(0)").focus();
                            }
                        }
                    );

                    $("input[type='password']:eq(0)").keyup(
                        function() {
                            if(event.keyCode == 13) {
                                $("input[type='button']:eq(0)").click();
                            }
                        }
                    );

                    $("input[type='button']:eq(0)").click(
                        function() {
                            var result = "";
                            result += "账户是:" + $("input[type='text']:eq(0)").val();
                            result += " ";
                            result += "密码是:" + $("input[type='password']:eq(0)").val();

                            alert(result);
                        }
                    );

                    //屏蔽默认的浏览器右键菜单
                    $(document).bind("contextmenu", function(e) {
                        return false;
                    });

                    //绑定自定义右键菜单
                    $(document).mouseup(
                        function() {
                            console.debug("Button:" + event.button);
                            if(event.button == 2) {
                                $("div")
                                    .css("left", event.x)
                                    .css("top", event.y)
                                    .show();
                            }
                        }
                    );
                });
            </script>
        </head>

        <body>
            <table border="0">
                <tr>
                    <th>账户:</th>
                    <td>
                        <input type="text" />
                    </td>
                </tr>
                <tr>
                    <th>密码:</th>
                    <td>
                        <input type="password" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center">
                        <input type="button" value="登录" />
                    </td>
                </tr>
            </table>
            <div style="border: solid blue 1px; 200px; height: 400px; display: none; position: absolute;">

            </div>
        </body>

    </html>

  • 相关阅读:
    转:IPhone之ASIFormDataRequest POST操作架构设计/ 处理网络超时问题
    LLDB和GDB比较
    为线程设置一个名字 [mythread setName:@"第一个子线程"];
    杀死一个线程
    ios 开发框架原始雏形 01
    iOS开发:设置应用程序图标和引导画面
    一个奇怪的现象 在GDB模式和LLDB 模式下 同样代码不同反应 AudioServicesCreateSystemSoundID
    iOS中GCD的魔力
    提升app 应用程序运行速度的几个常用方法
    IOS开发缓存机制之—本地缓存机制
  • 原文地址:https://www.cnblogs.com/zhouguoshuai/p/8192191.html
Copyright © 2011-2022 走看看