0

How can I make if click .a(bluearea) then .menu fadein,
but click .apic(apic is inside a) run fancybox and menu not fadein?

http://jsfiddle.net/e5Tdv/12/

jQuery

$('.apic').fancybox({});
$('.a').not('.apic').click(function(){
    $('.menu').fadeIn();
});

HTML

<div class="a">
    <a class="apic" rel="gallery" href="http://fancyapps.com/fancybox/demo/1_b.jpg">
        <img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt=""/>
    </a>
</div>
<div class="menu">menu</div>

CSS

.menu{
    display: none;
}
.a{
    background: blue;
}​
4

1 回答 1

3

您可以检查用户单击的位置(事件目标)并在未单击图像时淡出,例如:

$('.apic').fancybox({});

$('.a').click(function(e){
    $('.menu').hide(); // This is just to see that it works

    if ($(e.target).is('div')) {
        $('.menu').fadeIn();
    }
})

​</p>

看看在行动 - http://jsfiddle.net/Qeay5/

于 2012-10-27T08:57:03.927 回答