简体   繁体   English

jQuery Facebox插件:集中显示弹出窗口

[英]jQuery Facebox plugin: Focus the popup appearance

I have an HTML page with facebox popup. 我有一个带有Facebox弹出窗口的HTML页面。

This page contains many links and forms, and the popup contains one form. 该页面包含许多链接和表单,弹出窗口包含一个表单。 What I want is, when I open the popup, using only keyboard's buttons, to go directly to the form's inputs of the popup with 'tab' button. 我想要的是,当我仅使用键盘按钮打开弹出窗口时,可以直接使用“选项卡”按钮转到弹出窗口的表单输入。

Here is a fiddle --> http://jsfiddle.net/tk1jagpb/ 这是一个小提琴-> http://jsfiddle.net/tk1jagpb/

 $(document).ready(function () { $('a[rel*=facebox]').facebox() }) 
 .popup { background-color: mistyrose; } 
 <p><a href="#info" rel="facebox">Click to display</a></p> <div id="info" style="display: none;"> <p>Popup div</p> <p><input type="text" value = "" /></p> <p><input type="text" value = "" /></p> <p><input type="text" value = "" /></p> <p><input type="text" value = "" /></p> </div> <p><input type="text" value = "" /></p> <p><input type="text" value = "" /></p> <p><input type="text" value = "" /></p> 

If it were so, I might use the keyboard without having to click the popup box... It would save my time. 如果是这样,我可以使用键盘而不必单击弹出框...这样可以节省时间。

Thanks. 谢谢。

You can listen for the 'reveal.facebox' event which is fired just after the facebox is shown. 您可以监听'reveal.facebox'事件 ,该事件在显示facebox之后立即触发。 Once the facebox is shown, just focus the first input field. 一旦显示了facebox,只需将焦点放在第一个输入字段即可。

$(document).ready(function() {
    $('a[rel*=facebox]').facebox();
    $(document).bind('reveal.facebox', function() {
        $('.popup input:first').focus();
    });
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM