Make overlapping div "not clickable" so that content below can be accessed?

JavascriptJqueryCssEvent Listener

Javascript Problem Overview


I am using a JPG overlay with a reduced opacity for an effect, however I want it as an effect only and make the content below that div clickable. Is that possible, thanks :)))

Thanks for your comments everyone. I guess I'll have to think of something else because the JPEG covers the whole page :)

Javascript Solutions


Solution 1 - Javascript

Well there is pointer-events:none; but only few browsers modern browsers (and IE11) support it.

https://developer.mozilla.org/en/CSS/pointer-events

Solution 2 - Javascript

Yes, its possible

Use pointer-events: none along with conditional statements of CSS for IE11 (as it does not work in IE10 or below), you can get a cross browser compatible solution to achieve this.

Using AlphaImageLoader, you can even put transparent .PNG/.GIFs in the overlay div and have clicks propagate through to elements lying bellow.

CSS:

pointer-events: none;
background: url('your_transparent.png');

IE11 conditional:

filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='your_transparent.png', sizingMethod='scale');
background: none !important;

Here is a basic example page with all the code.

Solution 3 - Javascript

No, it's not. The overlaying element will always intercept the click. One possible workaround is to bind a click event to the overlaying element, and then get the current mouse position & compare that to the position of the element underneath in order to determine whether or not that element should register a click. But chances are there is a much better way of accomplishing this. Without seeing your code, however, I have no way of knowing.

Solution 4 - Javascript

one simple trick i have found, althoug not very w3c, is to encapsulate the div into a span and use that span class to make the overlay. That way the whole thing will be clickable , and the div will behave like a div

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpufAmufView Question on Stackoverflow
Solution 1 - JavascriptAndyView Answer on Stackoverflow
Solution 2 - JavascriptNaeem Ul WahhabView Answer on Stackoverflow
Solution 3 - JavascriptmaxedisonView Answer on Stackoverflow
Solution 4 - JavascriptMatoeilView Answer on Stackoverflow