If I have :
<div id="mydiv" onmouseover="myfunc()">
<div id="mydiv1"></div>
<div id="mydiv2"></div>
</div>
<script>
function myfunc() {
var evt = window.event || arguments.callee.caller.arguments[0];
var em = evt.target || evt.srcElement;
return em.id;
}
</script>
The function is called by mydiv onmouseover, but if mouse cursor is over mydiv1 function returns mydiv1.
How to make it always to show mydiv?
P.S : I know that I can use something like myfunc(this), but I would like to find caller from inside my function.
Personally I would prefer to use jQuery to hook up the event:
If this should be applied to several elements, then use a class selector instead:
To also handle future content, attach the event handler to a common ancestor, and select the hoverable elements in the second parameter to
on:See it in action with future content here.