jquery-ui对话框:在对话框中创建一个默认操作按钮(Enter键) [英] jquery-ui Dialog: Make a button in the dialog the default action (Enter key)
本文介绍了jquery-ui对话框:在对话框中创建一个默认操作按钮(Enter键)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在jquery模式对话框中,有没有办法选择按钮作为默认操作(当用户按下回车时要执行的操作)?
In a jquery modal dialog, is there a way to select a button as the default action (action to execute when the user presses enter)?
jquery示例网站:
jquery对话模式消息
Example of jquery web site: jquery dialog modal message
在上面的示例中,当用户按下Esc时,对话框将关闭。当用户按下Enter时,我想要调用Ok按钮动作。
In the example above the dialog closes when the user presses Esc. I would like the "Ok" button action to be called when the user presses Enter.
推荐答案
在对话框的打开功能中,你可以关注按钮:
In your dialog's open function, you can focus the button:
$("#myDialog").dialog({
open: function() {
$(this).parents('.ui-dialog-buttonpane button:eq(0)').focus();
}
});
更改:eq(0)
如果它是在不同的索引,或通过名称等找到。
Change the :eq(0)
if it's at a different index, or find by name, etc.
这篇关于jquery-ui对话框:在对话框中创建一个默认操作按钮(Enter键)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文