fancybox div中的本地链接不起作用

时间:2013-08-30 13:03:57

标签: javascript jquery html css

隐藏div用于Fancybox(v2)用法:

<div id="embargomsg" style="display:none">
    <h1 class="entry-title">You Can't Use That Yet</h1>
    <p>That's the special stuff.</p>
    <h2 class="pitch">New to the Site?</h2>
    <p class="pitch"><a class="button secondary promo" href="/register" target="_top"><span>Get Started Today</span></a></p>
    <h2 class="pitch">Already Registered?</h2>
    <p class="pitch"><a class="button secondary action" href="/login" target="_top"><span>Log In</span></a></p>
</div><!-- #embargomsg -->

页面中其他地方的一些authctrl类的链接应该打开fancybox ...

<a class="authctrl" href="/specialstuff1">Special Stuff</a>
<a class="authctrl" href="/specialstuff2">Some Other Special Stuff</a>

...使用此功能:

$('.authctrl').click(function(e){
    e.preventDefault();
    $('#embargomsg').fancybox({
    closeClick : false
    }).trigger('click');
});

...但是当点击任一.authctrl个链接时,Fancybox似乎只是快速关闭并重新打开。我尝试添加closeClick: false无济于事。

1 个答案:

答案 0 :(得分:0)

$('#embargomsg')是否有href?

$('.authctrl').click(function(e){
    e.preventDefault();
    $('#embargomsg').trigger('click');
});

$('#embargomsg').fancybox({
    closeClick : false
});

请提供一些标记。