focus()在colorbox弹出窗口内不起作用 [英] focus() doesn't work inside colorbox pop-up

查看:85
本文介绍了focus()在colorbox弹出窗口内不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 focus 作为表单上的第一个输入字段。但
它不起作用。当我为该输入调用 attr(id)时,它有效。当我为相同的输入调用焦点时,我没有看到任何
结果。我也尝试使用原生Javascript。有谁知道
如何修复?

I tried to use focus for first input field on the form. but it doesn't work. When I call attr("id") for that input it worked. When I call focus for the same input, I didn't see any result. I also tried to use native Javascript. Does anyone know how to fix that?

推荐答案

你们都误解了这个问题。当Colorbox打开时,您无法聚焦输入字段?

You are all misunderstanding the question. When Colorbox opens you can't focus an input field?

...除非您将焦点添加到Colobox onComplete键,例如

...unless you add your focus to the Colobox onComplete key e.g.

$('#mydiv a').colorbox({ onComplete:function(){ $('form input:first').focus(); }});

您还可以将焦点绑定到事件挂钩:

You could also bind the focus to an event hook:

$('#mydiv a').bind('cbox_complete', function(){
        $('form input:first').focus();
});

这应该足以开始。

这篇关于focus()在colorbox弹出窗口内不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆