处理z-index'd图层上的点击事件 [英] Handling click events on z-index'd layers
问题描述
我遇到的问题是事件不管是什么,但是事件的originalTarget属性不是底层中的图像,而顶层的东西是点击。有没有改变这个?
它被称为事件冒泡,你可以用 IE中的event.stopPropagation()
方法( event.cancelBubble()
)。您还可以通过从onwhatever属性调用的处理程序返回true / false来控制它。这是一个棘手的问题,所以我建议你做一些研究。
信息: cancelBubble , stopPropagation
I have 2 z-index layers in a map application I'm building. I have a problem when I click on the layers to zoom in. The click handler is on the underlying z-index layer and I don't want it to fire when a control in the overlying layer is clicked.
The problem i have is that the event gets raised no matter what but the originalTarget property of the event is not the image in the underlying layer when something on the top layer is clicked. Is there anyway to change this?
It's called event-bubbling, and you can control it with the event.stopPropagation()
method (event.cancelBubble()
in IE). You can also control it by returning true/false from handlers called by onwhatever attributes on elements. It's a tricky subject so I suggest you do some research.
Info: cancelBubble, stopPropagation
这篇关于处理z-index'd图层上的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!