2012-05-24 5 views
-1

Ok. .item.plain 반면중첩 된 앵커를 사용할 수 없습니다.

$('#exhibitions .item.plain').toggle(
    function() { 
     $(this).css({ 
      'height': '302px', 
      'z-index': '10', 
      'background': '#3F94AB' 
     }); 
     $(this).find('p.title').css('color', '#E6E6E6'); 
     $container.isotope('reLayout'); 
    }, 
    function() { 
     $(this).css({ 
      'height': "130px", 
      'z-index': '0', 
      'background': '#CCC' 
    }); 
    $(this).find('p.title').css('color', '#353334'); 
    $container.isotope('reLayout'); 
}); 

이 중첩 anchor와 사업부에 주어집니다 : 나는 다음과 같은 스크립트를 가지고있다. 그리고 그것을 클릭하면 분명합니다)) toggle() 해고됩니다.

<div class="item plain"> 
    <!-- some stuff --> 
    <a href="url I want to go"></a> 
</div> 

어떻게 수정합니까?

감사합니다.

+1

가능한 중복 이벤트의 전파를 중지 할 때 요소 .item.plain를 전환하지 않으려는 [내가 어떻게 방지 않는 자식 앵커를 클릭하면 부모의 onclick 이벤트가 실행되지 않습니다?] (http://stackoverflow.com/questions/1369035/how-do-i-prevent-a-parents-onclick-event-from-firing-when-a- child-anchor-is-cli) 및 [Child firing parent click event로부터 클릭 금지] (http://stackoverflow.com/q/6929198/218196) 및 [Child firing parent click event로부터의 클릭 방지] (http : // [Jquery 클릭 이벤트 전파] (http://stackoverflow.com/q/2244320/218196) –

+1

및 [자녀가 부모 클릭을 클릭하는 것을 방지하는 방법] (http://stackoverflow.com/q/8484847/218196) 및 [부모 클릭 onclick 이벤트를 유발하지 않아야하는 링크를 클릭하십시오] (http://stackoverflow.com/q/5590944/218196) 및 [DIV를 선택하고 그 안에있는 링크가 아니라 jQuery 질문] (http://stackoverflow.com/q/3838758/218196)을 참조하십시오. –

+0

@Felix 좋은 지적이지만, OP가 무슨 일이 일어나고 있는지 알지 못해서, 나는 이것이 합법적 인 질문이라고 생각할 것입니다. –

답변

4

내가 잘 이해하면 당신이 링크를 통해 클릭, 그래서이 방법의

$('#exhibitions .item.plain a').on('click', function(evt) { 
    evt.stopPropagation(); 
}); 
관련 문제