2012-11-20 66 views
2

你好我有一個網站我正在爲這個網站工作我正在做三個面板翻轉,當他們被點擊時,你可以把它想象成翻轉卡概念。我有一切工作,但我意識到,因爲div本身被包裹在一個錨標記,並具有「塊」的顯示。我所擁有的是內部鏈接到外部頁面的內容,但由於div是可點擊的,它只能讀取該錨點。我嘗試使用z-index,但似乎沒有幫助。什麼修復當前用作可點擊div的div內的鏈接

這是我的標記: 什麼是ElectedFace?

<div class="flip_content" id="flip1"> 
<div class="content-info"> 
    <h5 style="text-align:center; font-size:20px; margin:3px 0 0 0; font-family:Arial, Helvetica, sans-serif;"><span class="blue">Elected</span><span class="red">face</span></h5> 
    <p>electedface is America's free social network delivering more real time news, faster than any other website.</p> 
    <p>electedface connects subscribers to their elected officials with active electedface accounts</p> 

<p>electedface empowers subscribers to share their voice and turn social networking into constructive civil action.</p> 
    </div> 
</div> 

<a href="#" class="flip_switch" data-content_container="#flip2" data-flip_container="#flip_box2"> 
<div class="flipbox" id="flip_box2"> 
    <h4>Getting Started</h4> 
</div> 
</a> 

<div class="flip_content" id="flip2"> 
<div class="content-info"> 
    <p> There are three ways to connect:</p> 
    <p><a href="http://google.com">Read top news stories</a> and <a href="http://google.com">Read local news stories</a></p> 
    <p><a href="http://google.com">Connect to your elected officials and start a group in your community</a></p> 
    <p><a href="http://google.com">Register for free membership</a></p> 
    </div> 
</div> 
<a href="#" class="flip_switch" data-content_container="#flip3" data-flip_container="#flip_box3"> 
<div class="flipbox" id="flip_box3"> 
    <h4>Next Steps</h4> 
</div> 
</a> 
<div class="flip_content" id="flip3"> 
<div class="content-info"> 
    <p>Elected officials: activate your electedface account, connect to your electorate, and enlist supporters.</p> 
    </div> 
</div> 

繼承人我的JavaScript

<script type="text/javascript"> 
     $(function(){ 
      $('.flip_switch').bind("click",function(){ 
       var element = $(this); 
       var content = element.data("content_container"); 
       var flip_container = element.data("flip_container"); 
       var active_flipbox = $('.activeFlip'); 

       if(element.hasClass('activeFlip')){ 
        //If the flipbox is already flipped 
        flip_container.revertFlip(); 
       } 
       else{ 
        if(active_flipbox){ 
        //Revert active flipbox 
        active_flipbox.revertFlip(); 
        //Remove active status 
        active_flipbox.removeClass('activeFlip'); 
        } 
        $(flip_container).flip({ 
        direction: 'rl', 
        color: '#c8cbce', 
        content: $(content).html(), 
        speed:100, 
        onBefore: function(){ 
         $(flip_container).addClass('activeFlip'); 
        } 
        }); 
       } 

       return false; 
      });  
     }); 
    </script> 
+1

event.stopPropagation()可以防止默認行爲(瀏覽到''標籤的href)發生。但如何使用另一個標籤,如''而不是''? – AlexStack

+0

疲倦地爲javascript添加一個新的點擊功能,該功能將尋找具有位置鏈接和數據標記類別的span標記,並點擊它將從數據標記拉出鏈接並轉到它,但仍然沒有骰子。 –

回答

0

在我看來,你的問題是所謂的bubbling

你需要的是(最有可能的:) : http://api.jquery.com/event.stopPropagation/

+0

似乎沒有工作。我嘗試了主要的div錨,並試圖鎖定div內的錨鏈接。 –

+0

我終於想出瞭如何使用這個功能,謝謝。我不得不讓div可點擊而不是使用另一個錨標籤。 –

+0

歡迎您:) –