0
正如你可以在onComplete定义中看到的,我试图访问当前正在启动的特定DIV的HTML,但绑定调用是通过类完成的。如果我有许多DIV都是同一类,它就会被正确绑定,这意味着当我点击“.opener”锚点时,它会弹出正确的内容。但是我无法弄清楚如何从onComplete函数访问这些内容,因为它每次只回馈第一个“.opener”,而不管哪一个被启动。有任何想法吗?Fancybox:绑定多个具有相同类的DIV,但是如何在onComplete函数中单独访问它们?
initFancyBox: function() {
//ie hack for fancy box
if ($(".dialog").length > 0 || $(".imageDetail").length > 0) {
$(".opener").fancybox({
'titlePosition': 'inside',
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'inline',
'onComplete': function(){
alert($(".opener").parent().html());
}
});
} else {
$(".opener").fancybox({
'titlePosition': 'inside',
'transitionIn': 'none',
'transitionOut': 'none',
'type': 'image'
});
}
}
[的fancybox:获取点击的锚/元素的ID]的可能重复(HTTP: //stackoverflow.com/questions/2961496/fancybox-get-id-of-clicked-anchor-element) – BigOmega 2011-01-06 17:54:00