开发者

How to avoid the below div from receiving the event?

开发者 https://www.devze.com 2023-01-29 10:49 出处:网络
I have a div called "lower", and a div called "upper". The lower div has a dblclick event, and the upper div is nested inside "lower" (and appears on top) of the lower di

I have a div called "lower", and a div called "upper". The lower div has a dblclick event, and the upper div is nested inside "lower" (and appears on top) of the lower div. There is no dblclick event on the upper div.

How can I prevent the lower div from receiving the double click event when I double click the upper div?

$('#lower').dblclick(function(e){ 
    alert("event o开发者_JAVA技巧ccurred !");
});


If as @thejh suggests #upper is inside #lower, you could try this

$('#upper').dblclick(function(e){ 
            e.stopPropagation();
    }); 
0

精彩评论

暂无评论...
验证码 换一张
取 消