Unique JavaScript/DHTML Menu: Onmouseover/onmouseout scripting logic challenges -


i attempting create javascript menu employ following html:

<table id="mainmenu">   <tr>     <td id="mainmenu1">item 1</td>     <td id="mainmenu2">item 2</td>     <td id="mainmenu3">item 3</td>   </tr> </table>  <table id="submenua" style='hidden';>   <tr>     <td>subitem a1</td>     <td>subitem a2</td>     <td>subitem a3</td>     </tr> </table> <table id="submenub" style='hidden';>   <tr>     <td>subitem b1</td>     <td>subitem b2</td>     ... 

when #mainmenu1 onmouseover, want #submenua.style='visible'.
when #mainmenu1 onmouseout, want #subheadera.style='hidden'.
when #submenua onmouseout, want #subheadera.style='hidden'.

note traditional drop-down scripts don't work because 2 menus 2 separate elements , there small distance between them. it's therefore necessary "bridge gap" between 2 elements. how this??

could suggest basic javascript code working? logic/idea great. appreciate it!

updated answer: http://jsfiddle.net/imsky/zcwjt/4/

var $ = function(el) {     return document.getelementbyid(el) };  var menu_timer;  $("item1").onmouseover = function() {     window.cleartimeout(menu_timer);     $("menu1").style.display = "block"; }  $("menu1").onmouseover = function() {     window.cleartimeout(menu_timer); }  $("menu1").onmouseout = function(e) {     window.cleartimeout(menu_timer);     if (!parent(e.relatedtarget, this)) {         var menu = this;         menu_timer = window.settimeout(function() {             menu.style.display = "none";         }, 1000)     } }  var parent = function(el, p) {     if (!el) {         return false;     }     if (el !== p) {         while (el.parentnode) {             el = el.parentnode;             if (el == p) {                 return true;             }         }     }     else {         return true;     }     return false; } 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -