Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass a click through an element?

I want to display an image under the mouse (a finger to simulate a touch screen) when a mousedown event occurs and hide it when the mouseup event occurs, but when I do this, the image I display blocks the subsequent mouse events ("click" in particular) on elements under this image. I'm using jQuery, by the way.

I'm sure this is something to do with event bubbling or propagating or somewhat, but I couldn't figure it out. Any pointers please?

like image 760
Paul Higgins Avatar asked Mar 22 '11 22:03

Paul Higgins


People also ask

How do you click through elements in CSS?

Just use the pointer-events:none css property to allow click events to go through the element.

How do I turn off the click element?

$('selector'). click(false);

How do you stop click in CSS?

To disable clicking inside a div with CSS or JavaScript, we can set the pointer-events CSS property to none . Also, we can add a click event listener to the div and then call event. preventDefault inside.


1 Answers

Check out this answer to on this post:

https://stackoverflow.com/a/4839672/589909

It seems to do what I understand what you want to achieve using a pure cross browser CSS approach.

pointer-events:none; touch-action:none;

like image 193
brenjt Avatar answered Oct 05 '22 16:10

brenjt