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

Got a Question?

Get answers here.

7 Comments »

  1.  

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

    Comment

  2.  

    Thank you Hamid!

    This is exactly what I’ve been looking for. Your code works beautifully! Thanks!

    Comment

  3. Santhosh:
     

    Thank you Sir…

    this code works very well… being searching for this code… :)

    Comment

  4.  

    This is the exact code i was searching for. Works well in IE 8 and Firefox.

    Thank you very much.

    Comment

  5.  

    Great one!
    thx.

    Comment

  6. Seeker:
     

    You Rock!

    Thanks!

    Comment

  7. Sumit:
     

    Great help. Thanks a ton :)

    Comment

RSS feed for comments on this post. TrackBack URL

Leave a comment