2012-02-15 112 views
0

我试图让div显示和隐藏点击。 目前主分区名为#MAIN (1)应该是默认分区。所以当我点击这个框时,主div再次出现。jquery隐藏和显示基于索引,方式?

我已经更新了FIDDLE,现在我应该将数字1作为默认值,一旦我点击容器 (例如, http://jsfiddle.net/srg6g/480/

+0

那的jsfiddle有一个很奇怪的输出。 – MetalFrog 2012-02-15 13:45:04

+0

我已经更新了FIDDLE,我现在应该将数字1作为默认值,一旦我点击了容器 – DD77 2012-02-15 13:47:17

+0

@MetalFrog现在应该更有意义我认为 – DD77 2012-02-15 13:55:16

回答

1

我想我终于明白了你以后的样子。

你需要的是这样当的“数字”以外的用户点击,则#MAIN再次显示在文档绑定click事件:在热点时,点击

$('html').click(function() { 
    // use :not() to avoid fading when #MAIN is the current 
    $(".hotspot_bub:not(#MAIN)").fadeOut('slow'); 
    $("#MAIN").show(); 
}); 

,并停止传播:

$("#MAIN").show(); 
$('a.a_hotspot').click(function(e) { 
    e.preventDefault(); 

    // so the click handler on "html" is not executed 
    // when clicking on a hotspot 
    e.stopPropagation(); 

    $(".hotspot_bub").fadeOut('slow'); 
    $(this).next().fadeIn('slow'); 
}); 

DEMO

+0

血腥的好感谢 – DD77 2012-02-15 14:32:24

+0

很高兴帮助; o) – 2012-02-15 14:34:10

+0

非常好的工作,@DidierGhys – MetalFrog 2012-02-15 14:40:57