2012-01-27 5 views
0

親divの「.row」をクリックして、その親divの中のリンク「.ExpandPane」を表示すると、リスト内の要素を切り替える次のコードがあります".row"をクリックすると、トグル機能も有効になりますリンクを取得する親divをトグルしないようにする

私はこれを解決できる方法はありますか?親のdiv ".row"のどこかをクリックして、トグル機能をアクティブにしないで通常のように機能する。 Htmlの

<div class="Row"> 
    <a class="acceptBtn"></a> 
    <p>content.....</p> 
    <div class="ExpandPane"></div> <!-- hidden --> 
</div> 
<div class="Row"> 
    <p>content...</p> 
    <a class="acceptBtn"></a> 
    <div class="ExpandPane"></div><!-- hidden --> 
</div> 
<div class="Row"> 
    <p>content....</p> 
    <a class="acceptBtn"></a> 
    <div class="ExpandPane"></div><!-- hidden --> 

</div> 

jQueryの

$(".Row").toggle(
     function() { 
     $(this).find('.ExpandPane').show(); 
     //$(this).find('.PhotoShow').hide(); 
     //$(this).find('.PhotoHide').show(); 

     }, 
     function() { 
     $(this).find('.ExpandPane').hide(); 
     //$(this).find('.PhotoHide').hide(); 
     //$(this).find('.PhotoShow').show(); 
     }); 


$(".acceptBtn").click(function(event) { 
    alert("hi"); 
}); 

答えて

0
$(".acceptBtn").click(function(event) { 
    alert("hi"); 
    event.stopPropagation(); 
}); 

stopPropagation()

はあなたの親のdivまでバブリングからイベントを防ぎます。また、この質問は約100回答えられています。

関連する問題