Note that there are some explanatory texts on larger screens.

plurals
  1. POClosing multilevel jquery dropdown menu
    primarykey
    data
    text
    <p>I have a dropdown menu the expands on clicks rather than hover. The problem is that when i open submenus i can't get them to close as i move the mouse from the current submenu to it's parent menu. It should hide the previous menu all the way up to the navigation bar(top) and hide all menus once i leave any of its children menus and hover over the body of the page.</p> <p>Fiddle: <a href="http://jsfiddle.net/WjE9y/11/" rel="nofollow">http://jsfiddle.net/WjE9y/11/</a> </p> <p>HTML:</p> <pre><code>&lt;!-- &lt;LINK REL="SHORTCUT ICON" HREF="favicon.ico"&gt; --&gt; &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="includes/menu.js"&gt;&lt;/script&gt;&lt;/script&gt; &lt;link type="text/css" href="includes/menu.css" rel="stylesheet" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div style="z-index:100;width:100%;position:fixed;top:0;left: 0;min-width:1000px;"&gt; &lt;div id="menuJQ"&gt; &lt;ul class="menuJQ"&gt; &lt;li class="parent"&gt;&lt;a href="#"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a class="parent" href="#"&gt;&lt;span&gt;Product View&lt;/span&gt;&lt;/a&gt; &lt;div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;DevTask Search&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Active Machines&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="parent"&gt;&lt;a href="#"&gt;&lt;span&gt;Request Tool&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="parent"&gt;&lt;span&gt;Search&lt;/span&gt;&lt;/a&gt; &lt;div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;DevTask Search&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Active Machines&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Integrity Query&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Internal DevTasks&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" class="parent"&gt;&lt;span&gt;Results&lt;/span&gt;&lt;/a&gt; &lt;div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#" target='_blank'&gt;&lt;span&gt;Latest Smoke Results&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" target='_blank'&gt;&lt;span&gt;Latest Smoke Results&lt;/span&gt;&lt;/a&gt; &lt;div&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;DevTask Search&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Active Machines&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Integrity Query&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span&gt;Issues for Stability Team&lt;/span&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><br> JS:</p> <pre><code>$(document).ready(function(){ $(function() { $('#menuJQ &gt; ul li').click(function(e) { e.preventDefault(); $('ul:first', this).show(); }); }); var submenu_active = false; $('#menuJQ ul').mouseenter(function() { submenu_active = true; }); $('#menuJQ ul').mouseleave(function() { submenu_active = false; setTimeout(function() { if (submenu_active === false) $('ul', this).hide("fast");}); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload