If I have a parent div that contains a child div on top of it, can I give the parent div the focus without hiding the child div?
I am using Google Maps API and would like to draw a grid of transparent divs on top of it for inserting information, however, with all of those little divs on top of my map, I cannot drag the map.
I'm sure I can do it using the API but that's sort of beside the point, because I would like to do this regardless of what I'm working on top of.
<div style="position: relative; width: 100px; height: 100px;" id="wanttofocus">
<div style="position: absolute; width: 100px; height: 100px;"
id="want_to_see_but_dont_want_to_focus_on">Some overlay information</div>
</div>
I am using JQuery and messed around with .focus()
but that didn't work out.
THANKS!
If an element with opacity less than 1 is positioned, the 'z-index' property applies as described in [CSS21], except that 'auto' is treated as '0' since a new stacking context is always created.
To sum up, most issues with z-index can be solved by following these two guidelines: Check that the elements have their position set and z-index numbers in the correct order. Make sure that you don't have parent elements limiting the z-index level of their children.
Set the DIV's z-index to one larger than the other DIVs. You'll also need to make sure the DIV has a position other than static set on it, too. position relative and z index set to 999999999999999999999999999999999999999999999999999.
Turns out, you can "passthru" events with jQuery:
$(document).ready(function(){
$('#want_to_see_but_dont_want_to_focus_on').bind('mousemove mousedown mouseup', function(e){
$("#wanttofocus").trigger(e); // passing thru the event
});
$('#wanttofocus').bind('mousemove mousedown mouseup', function(e){
$('.status').html(e.type + ' ' + e.pageX + ' ' + e.pageY);
});
});
I've thrown together a jsFiddle, feel free to play: http://jsfiddle.net/gK6Aa/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With