I have an element <span>
which partly covers another element <div>
.
The div element has a hover state, so I have applied pointer-events: none !important;
to the span so that the hover state remains active when the mouse is over the portion of the div that is covered by the span.
This works good in most browsers - Not in IE though :(
I'm trying a couple of jQuery suggestions to try to keep the hover state on the div element. Something along the lines of this could work:
$("span").hover(
function(){
$("div").hover();
}
);
eg: When hover the span, emulate hover the div.
I also tried this:
$("span").hover(passThrough);
function passThrough(e) {
console.log("going");
$("div").each(function() {
// check if hovered point (taken from event) is inside element
var mouseX = e.pageX;
var mouseY = e.pageY;
var offset = $(this).offset();
var width = $(this).width();
var height = $(this).height();
if (mouseX > offset.left && mouseX < offset.left+width
&& mouseY > offset.top && mouseY < offset.top+height)
$(this).hover(); // force hover event
});
}
(taken from here) eg: When hover the span, if the mouse is over the div, emulate a hover.
Would you have any suggestions how this would work well?