frenchdev20 frenchdev20 - 8 days ago 4x
jQuery Question

How to trigger an event when target element is under another div

Here is my initial HTML Structure

<div id="cover"></div>

At my div #cover apply a plugin for dragging it. I used this library : kentor/jquery-draggable-background and worked fine !

BUT When I would like add an overlay div like this :

<div id="cover">
<div id="cover-overlay"></div>

the desired behavior of my div #cover is no longer triggered (I guess it comes from because my div#cover is "under" the div#cover-overlay.

Here my JSFiddle : : You can test the normal behavior by removing the div #cover-overlay and dragging the div (in Y axis) in the results.

My question : How to trigger the desired behavior of my div#cover in this case ?

Thanks you for your help !


Did you try adding

$('#cover-overlay').css('pointer-events', 'none');

At least this works in your fiddle. However, it will not work in IE10 and lower.