내 코드는 HTML에 다음처럼 사용하는 방법 : (요소를 동적으로 표시하기 때문에)위임에 event.stopPropagation을()()
<li class="arrow">
<div>
<a href="javascript:void(0);" class="anchor">remove</a>
</div>
</li>
내가 deligate() JQuery와 방법을 사용하여 내 요소를 결합
$obj.delegate(".arrow", "click", function() {
alert("clicked on arrow");
});
$obj.delegate(".anchor", "click", function(event) {
event.stopPropagation();
alert("anchor clicked");
});
".anchor"를 클릭하면 두 가지 이벤트가 발생합니다. 누구든지이 컨텍스트에서 event.stopPropagation()을 사용하는 방법을 말해 줄 수 있습니까? 위와 같았으나 작동하지 않았습니다. 이것을 할 수있는 다른 방법이 있습니까?
편집 : 나는 event.isPropagationStopped()를 호출 해 보았는데 true를 반환했다. 그러나 여전히 두 사건 모두 불렀다.
: 여기
은 예입니다? – Zimbabaohttp://stackoverflow.com/questions/1522941/event-propagation-in-javascript – Andreas