Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

z-index and Javascript events

I have a couple of divs overlaid on each other with differing z-index values.

The default behaviour for browsers seems to be the event bound to the top-most z-index div gets fired. I.e. I have multiple onclicks one for each div but only the top one is fired when the area is clicked.

Is there a way to fire the events attached to all divs no matter what the z-index of each is, so long as the action is 'over' that div without regard to z-index?

like image 633
blippy Avatar asked Dec 20 '09 19:12

blippy


1 Answers

The event doesn't actually occur on the element that is obscured by another unless the other element is contained in the first, then it will bubble up. The only way that I can think of to achieve what you want is to go through all of the potential elements and see if any of them contain the point at which the click occurred and trigger a click on that element (if it's not the current one).

like image 115
tvanfosson Avatar answered Nov 04 '22 21:11

tvanfosson