English 中文(简体)
绝对定位 DIV 位置, 高Z- Index 屏蔽在下面的点击事件
原标题:Absolutely Positioned DIV with a High Z-Index Is Blocking Click Events Below it

以下是我想做的:

创建一个绝对定位、宽度和高度为100%的全球“ 牙冻容器”, 并创建一个比文档中所有其他元素都高的z- index 。

Here is my problem: When I create this container, my absolutely positioned element is blocking the click events that are bound to everything that is below it.

$(document).ready(function() {
    $(document).on( click touchstart ,  .block , function() {
        var $this = $(this);

        if(!$this.hasClass("disabled")){
            $this.addClass("disabled")
            $this.openPopUp();
        }
        return false;           
    });
});

请注意,我正在使用来自jQuery 1. 7. 2的新.on () 呼叫, 我设置该呼叫的功能与. live () 相同。

为什么我的元素不接受我的点击?看起来我的手势区域挡住了它,但有办法绕过它吗?

最佳回答

解决方案一. CSS. 设置 < code> 指针- events: non; , 但只对 Firefox、 Chrome 和 Safari 有效 。

解决方案二. JavaScript.http://www.vinylfox.com/forwarding-mouse-events-trough-layers/

问题回答

我不认为您可以推翻它。 基本上, 事件是如何运作的, 这就是为什么您可以在屏幕中心显示一个对话框, 并在屏幕中单击它, 而不对对话框下方的元素启动同样的事件 。

你可以在这个更高的元素上做类似元素, 但是这看起来像点击抓劫, 一些浏览器卡登可能标记您的网站有潜在风险 。

以下是关于这个议题的类似讨论:HTML“overlay”使点击能够掉到后面的元素





相关问题
Mysql trigger/events vs Cronjob

I have an auction website which let my users place an unlimited amount of autobiddings. To monitor these autobiddings something has to check the database every second. My question is if it is ...

Can an event be used as an event listener?

I m trying to expose some events from a private object which is contained inside the object I am creating and it looks like the compiler is happy with this: private WindowUpdateServer ...

鸡奸

由于将javascript DOM方法放在第html页底部(在<有人>之后)远比利用“j Query”准备活动要快得多,因此我们不得不这样做:

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

jQuery bind on ajax load() event

I have a page which displays multiple blocks with results details. Inside each block I have some <a> tags with thickbox jQuery plugin attached: class="thickbox" Here is an example of one kind ...

HTML text input event

I have a form, and want to disable/enable its submit button depending on whether the form s input text fields are empty or have had text entered into them. I think this means having an event handler ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签