Take the 2-minute tour ×

I have a div and then a div with a nested table inside it: also there is some div outside the parent div.

<div onmousemove="move()" onmouseout="out()">
  <div id="dvRep"> </div>
        <tr><td>ITEM 1</td></tr>
        <tr><td>ITEM 2</td></tr>
        <tr><td>ITEM 3</td></tr>
        <tr><td>ITEM 4</td></tr>
        <tr><td>ITEM 5</td></tr>

<div id="divChartPopupMenu">
    Hide me.     

Whenever i move my mouse within the div it correctly calls the move function, but the onmouseout attribute doesn't work like i thought. i thought that the out() function would only be called if you moved your mouse off the div, but out() is called whenever i move off one of the table rows. so if my mouse is on a row and i move to the next row it calls out(). i want out() to be called only when the user moves off the entire div. any ideas?

What i am trying is on out function i am hiding another div.

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

i suggest you to read this article on 3 phases of javascript events.

in the function move or out, you can check if the srcElement(IE) or target(W3C) has an id called dvRep..

it should look something like this:

function out(event)
   event.stopPropagation(); //cancel bubbling

   ele = event.target || event.srcElement
   if (ele.id === "dvRep"){  
      //your code
share|improve this answer
add comment

It sounds like you're having issue with event bubbling.

When you hover a tr you're mouse is no longer 'in' the div - therefore when you move between them you're going tr (out) -> div (in) -> div (out) -> tr (in). That's why you're out() function is being called between tr's.

Useful reading:

share|improve this answer
add comment

What the heck? I found the exact same posting on a different forum from 7 years ago?? http://www.webdeveloper.com/forum/archive/index.php/t-65078.html

share|improve this answer
Good finding +1. –  Pavan Feb 1 '12 at 10:31
yup you are right i didn't had the time to right all the things so i posted most of the part from there. –  ankur Feb 1 '12 at 10:39
... but you didn't read the response pointing to event bubbling issues? –  devnull69 Feb 1 '12 at 10:40
I read that but what i was doing and the post was about is differnet. –  ankur Feb 1 '12 at 10:41
add comment

Your Answer


