我有一个fancybox,ajax调用file.php来显示内容。file.php包含:
<SCRIPT>
jQuery(document).ready(function($) {
$('[name=replyMsg]').focus();
});
</SCRIPT>但是当框打开时,它仍然不会聚焦在元素上。
我如何解决此问题/任何解决方案?
我的fancybox设置如下所示:
$("a.fancybox_wallConv").each(function(){
$(this).fancybox({
titleShow : false,
width: 380,
height: 190,
autoDimensions: false,
overlayOpacity: 0.3,
showNavArrows: false,
centerOnScroll: true,
href: "file.php"
});
});我使用href函数进行ajax调用。
http://fancybox.net/api
发布于 2010-12-22 06:59:55
您试图在fancybox出现之前调用focus()。将调用放在onComplete()中,而不是放在ready()中。
$("a.fancybox_wallConv").each(function(){
$(this).fancybox({
titleShow : false,
width: 380,
height: 190,
autoDimensions: false,
overlayOpacity: 0.3,
showNavArrows: false,
centerOnScroll: true,
href: "file.php",
onComplete: function() { $('[name=replyMsg]').focus(); }
});
});https://stackoverflow.com/questions/4504742
复制相似问题