You Are Here Home > onMouseOut fix on nested elements – JavaScript

onMouseOut fix on nested elements – JavaScript

When you have nested elements and you add an onMouseOut event handler to the parent element, browsers trigger onMouseOut event when mouse pointer hovers it’s child elements.
While this is a standard behaviour, for one project I needed to write a code to override this behaviour.
With this code, when you mouse over the child elements, onMouseOut event will be ignored.

You can download this code here:
http://images.code-head.com/code/javascript/fixOnMouseOut.zip

You can test it here:
http://images.code-head.com/code/javascript/fixOnMouseOuttest.html

This code is cross browser and here is how to use it:

<script language="javascript" type="text/javascript" src="fixOnMouseOut.js"> </script>
<div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');">
   So many child elements
</div>
onMouseOut fix on nested elements – JavaScript
Filed under: JavaScript, Web Design, Web Development   Posted by: Codehead on February 3, 2010

Disclaimer
1 - Use the information provided here at your own risk.
2 - You may not republish this content without prior written consent.




1 Comment »

  1.  

    wow, that’s great! Thank you very much!!!!

    Comment — March 8, 2010 @ 6:04 am

RSS feed for comments on this post. TrackBack URL

Leave a comment