2013-11-23 73 views
0

的這裏是我的網頁:http://frankjuval.com/web/playground/jQpage/index.htmljQuery:單擊外部Div關閉它;擺脫亮點

  1. 我希望能夠在彈出的div(即視頻1視頻2視頻3),並讓他們靠近外單擊。

  2. 出於某種原因,當你點擊的圖像地圖的地區,有一個藍色的亮點。我該如何擺脫?

僅供參考,我才能從彈出的div打開時移停止頁面中使用了「function(e){ e.preventDefault();」。

就是這樣。

這裏的HTML:

<div class="page"> 

    <div id="map"> 
     <img src="images/content_transparency.png" alt="all_content" width="1324" usemap="#3dmap"> 
    <map id="3dmap" name="3dmap"> 
     <area id="graphic1" shape="rect" coords="271,811,561,1208" href="#video1" /> 
     <area id="graphic2" shape="circle" coords="646,910,55" href="#video2" /> 
     <area id="graphic3" shape="rect" coords="711,898,1016,1204" href="#video3" /> 
     <area shape="default" nohref="nohref" title="Default" alt="Default"/> 
    </map> 
    </div><!-- END MAP --> 

    <div id="video1" style="display: none;"> 
     <img src="images/video1.png" alt="video-Overlay_IOA" width="624"> 
    </div> 

    <div id="video2" style="display: none;"> 
     <img src="images/video2.png" alt="video-Overlay_HE" width="624"> 
    </div> 

    <div id="video3" style="display: none;"> 
     <img src="images/video3.png" alt="video-Overlay_USF" width="624"> 
    </div> 

</div> 

CSS:

.page { 
    background: #000 url(../images/PainterlyWater_02.jpg) no-repeat center center fixed; 

} 

body { 
    width: 100%; 
    height: 100%; 
} 
.page { 
    width: 100%; 
    height: auto; 
    position: relative; 
} 
#map { 
    width: 1020px; 
    height: auto; 
    margin: auto; 
    overflow: hidden; 
    position: relative; 

} 
#map img { 
    display: block; 
    margin: auto auto auto -17px; 

} 

#video1, 
#video2, 
#video3 { 
    width: 624px; 
    height: 477px; 
    position: absolute; 
    top: 18%; 
    left: 36%; 
    overflow: hidden; 
} 

的jQuery(在HTML頁面中):

$(function(){ 

// VIDEO 1 
$("#graphic1").click(function(e){ 
    e.preventDefault(); 
     $("#video1").fadeToggle(400); 
     $(this).toggleClass("active"); 
     }); 

     $("#video1").click(function() { 
     $("#video1").hide() 
     }); 

// VIDEO 2 
$("#graphic2").click(function(e){ 
    e.preventDefault(); 
     $("#video2").fadeToggle(400); 
     $(this).toggleClass("active"); 
     }); 

     $("#video2").click(function() { 
     $("#video2").hide() 
     }); 

// VIDEO 2 
$("#graphic3").click(function(e){ 
    e.preventDefault(); 
     $("#video3").fadeToggle(400); 
     $(this).toggleClass("active"); 
     }); 

     $("#video3").click(function() { 
     $("#video3").hide() 
     }); 


}); 

回答

1

,而不是e.preventDefault();使用e.stopPropagation()停止文檔事件觸發它。 note注意.preventDefault()僅用於當您單擊鏈接或提交按鈕時不希望頁面重定向。