Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否在“提交”上提交;输入“;jquery diglog插件中的选项?_Jquery_Event Handling_Dialog - Fatal编程技术网

是否在“提交”上提交;输入“;jquery diglog插件中的选项?

是否在“提交”上提交;输入“;jquery diglog插件中的选项?,jquery,event-handling,dialog,Jquery,Event Handling,Dialog,网址如下: 假设此对话框包含两个按钮:“确定”和“否” 当按下“回车”键时,我希望调用绑定了“OK”按钮的函数 怎么做 该对话框如下所示: <table cellpadding="0" border="0" width="100%"> <tr align="center"> <td align="right">name/email:</td> <td><input type="text"

网址如下:

假设此对话框包含两个按钮:“确定”和“否”

当按下“回车”键时,我希望调用绑定了“OK”按钮的函数

怎么做

该对话框如下所示:

<table cellpadding="0" border="0" width="100%">
    <tr align="center">
        <td align="right">name/email:</td>
        <td><input type="text" id="name" /></td>
    </tr>
    <tr align="center">
        <td align="right" valign="top">password:</td>
        <td>
                <input type="text" id="psw" />
        </td>
    </tr>
    <tr align="center">
        <td></td>
        <td><span id="loginErr"></span></td>
    </tr>
</table>
$("#name").keydown(function(event){
    if(event.keyCode == "13") {
        // call the function for submit the form
    }
});

姓名/电邮:
密码:

将“Ok”按钮指定给一个标签,并给它焦点(如果第一件事情本身不能正常工作)

不,该功能不是现成的,你需要自己添加它,或者找到一个添加它的插件(我不知道我头顶上有一个插件)


一种可能的解决方案是侦听对话框的
keyup
事件,并确定它是否源自
元素。如果是这样,请查询对话框中按钮成员的选项,并调用第一个按钮的处理函数(与单击默认按钮非常接近)。

您可以通过添加选项对象轻松添加自定义按钮

buttons: {
'Button OK': function() {
  // Do something
 },
'Button No': function() {
  // Do something
}
要按enter键提交表单字段,只需执行以下操作:

<table cellpadding="0" border="0" width="100%">
    <tr align="center">
        <td align="right">name/email:</td>
        <td><input type="text" id="name" /></td>
    </tr>
    <tr align="center">
        <td align="right" valign="top">password:</td>
        <td>
                <input type="text" id="psw" />
        </td>
    </tr>
    <tr align="center">
        <td></td>
        <td><span id="loginErr"></span></td>
    </tr>
</table>
$("#name").keydown(function(event){
    if(event.keyCode == "13") {
        // call the function for submit the form
    }
});
所有钥匙码的完整来源请在此处找到:

采用snuffer ch建议的方法或使用jQuery热键插件,该插件允许您执行以下操作:

$(document).bind('keydown', 'return', function(){
  //your code goes here
});

看我的更新,不能集中在按钮上。当集中在一些