我正在嘗試確定如何暫時禁用來自其他元素的點擊事件(或傳播?)。 所以當你點擊特定元素上的事件時,其他元素點擊事件不再被觸發。停止在不同元素上傳播
Simplified Example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div id="World">World</div>
<div id="Hello">Hello</div>
<script>
$(document).mousedown(function (e){
if($('.there').length){
$('.there').remove();
console.log('removed there');
//here is where I would need the '#World' click event to not fire
}
});
$(document).on('click','#World',function(){
console.log('World');
});
$(document).on('click','#Hello',function(){
console.log('Hello');
$(this).append('<div class="there">there</div>');
console.log('added there');
});
</script>