【发布时间】:2011-06-15 14:02:16
【问题描述】:
我对fancybox 有疑问,我想将其应用于div 中的图像,它使用.replaceWith 动态更改其内容。代码如下所示:
$(document).load('fancybox', function() {
$('.various4').fancybox({
'width' : 800,
'height' : 750,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
});
这适用于以下 HTML:
<a class="various4" href="http://xy//index.html"><img height="400" width="600" src="bg.jpg" class="hoverbild" /></a>
由于我在 jquery 中使用悬停功能,并且正在更改 div 的内容,因此我使用以下代码在更改 div 的内容后提供悬停效果:
$(document).delegate('.hoverbild', 'hover', function(){
$(".hoverbild").hover(function() {
$(this).attr("src","bg-hover.jpg");
}, function() {
$(this).attr("src","bg.jpg");
});
});
这没有问题。但是现在,如果想告诉 fancybox-part 委托,它根本不起作用。没有错误警告,只是被忽略了。
$(document).delegate('.various4', 'fancybox', function(){
$('.various4').fancybox({
'width' : 800,
'height' : 750,
'autoScale' : false,
'transitionIn' : 'none',
'transitionOut' : 'none',
'type' : 'iframe'
});
});
我错过了什么?我尝试改用 .live,但这并没有什么不同。
提前感谢您的帮助。
【问题讨论】: