|Cancel OnMouseOver Event on nested divs|
onmouse event on nested divs
| 6:39 pm on Aug 22, 2008 (gmt 0)|
I have a container div that has an onmouseout event that basically shrinks it's size, and within this div, I have two block level elements, a nested div and an image. What's happening is while the mouse is still within the container div, and mouseover's either the nested div or the image, it triggers the onmouseout event on the container event.
For an example, see <snip>
How can I cancel the onmouseout event when it goes into the nested block elements, but keep it active for when the mouse actually leaves the outside edge of the container div?
Reps to the first fix!
[edited by: DrDoc at 9:20 pm (utc) on Aug. 23, 2008]
[edit reason] No URIs, please. See posting guidelines. [/edit]
| 3:30 am on Aug 25, 2008 (gmt 0)|
| 2:16 pm on Aug 25, 2008 (gmt 0)|
Perhaps you could use setTimeout and cancelTimeout.
Instead of shrinking the size onmouseout, call setTimeout to shrink the size after some small amount of time (maybe 300ms). Then, add an onmouseover listener that will call cancelTimeout to prevent the method for shrinking the size from being called. Therefore, if you are mousing over any of the nested items, the call to shrink the size will always be cancelled before it can call that method.
| 7:20 pm on Aug 25, 2008 (gmt 0)|
thanks for the reply, your response worked the best.
I set the onmouseout event on the container div to:
and on the nested div,
Worked like a charm! Thank you, I wasn't aware of a clearTimeout function.
| 7:21 pm on Aug 25, 2008 (gmt 0)|
csuguy, thanks for your reply as well, unfortunately, the onmouseout fires before the mouseover, so I couldn't update any global variables before the onmouseout fired. I tried it with a setTimeout, but it got messy.
| 9:23 pm on Aug 25, 2008 (gmt 0)|
Ah well - glad you got it working!