views:

246

answers:

2

I got image which is partialy overlapped by DIV, this particular image got its border set with CSS in external file to change color when mouse is over image.

problem is when i move mouse from image to div overlapping it, then image losts hover and border is going back to normal state.

How to tell to element with particular ID that mouse is still over it when i enter div above image? I've managed to make detection when mouse is hover DIV but no results with telling to image that mouse is still over it

i want to avoid using altering CSS

$("#imageID").css('border-color','#FFF');

and in some other way cause that behaviour which i'm looking for?

Thanks in advance for answers MTH

+1  A: 

Well if this particular div is always floating over the same image then you can add a "hover" class to the lower image when the mouse is hovering the upper div. Then you can still style the image with hover class in your css file.

HTML

<div id="divID"></div>
<img id="imageID" src="" />

jQuery

$("#divID").hover(function() {$("#imageID").addClass("divHover");}, 
                  function() {$("#imageID").removeClass("divHover");});

CSS

#imageID { border-color: #000; }
#imageID:hover, #imageID.divHover { border-color: #FFF; }
Tim Santeford
Well that is almost what i'm looking for but it is kind of workaround if any better simpler way to cause hover over image under div exist
MoreThanChaos
if the parent div of both the image and the floating div tightly wrapped the image and the floating div stayed directly over the image and never overlapped the edge then you might be able to style on the parent div's hover: #parentID:hover #imageID { style }
Tim Santeford
A: 

Z-index might help. Usually tags are ordered by when they're named. With z-index in css you can change the div to a lower z-index than the image. I'm not sure it'll work in all browsers though w3c says it is, YMMV. W3C z-index

Elizabeth Buckwalter
I need that DIV to be over image, goal to achieve is keep image hover when mouse is over div
MoreThanChaos
Ah Tim's answer is better than. If only there was a directive that would give precedence like you need, instead of the work around. But I'm pretty sure there isn't. Go with Time answer
Elizabeth Buckwalter