Submenu help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

Submenu help

Post by Pineriver »

Trying to create a submenu with a tables and divs from a db, when the mouse is
rolled onto a item a submenu would expand using onmouseover and closed again using
onmouseout.

I got everything worked out but the only thing I cant get to work
is on the <div> that expands the main menu, the onmouseout is being activated
when the mouse is being moved over the sub menus which are the
<tr> and not the main menu <div>.

This is the basic jist of the code that I have a problem with.

Code: Select all

<div onMouseOut="alert('Mouse is out')">
  <table width="117" height="78" border="0" cellpadding="0" cellspacing="0">
    <tr> 
      <td width="117" height="19" bgcolor="#006699"> Sub menu 1</td>
    </tr>
    <tr>
      <td height="20" bgcolor="#006699">Sub menu 2</td>
    </tr>
  </table>
</div>


I've looked on some over submenus that others have created and they use <div>
and<span>, but same problem I have gotten. Might there be a fix to this that
anyone could see?

Thanks
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

This is a common problem, because whenever you move your mouse over a sub-element, the DOM object changes and thus onmouseout fires.

BrainJar has a good tutorial on this:

http://brainjar.com/dhtml/events/default3.asp
Post Reply