Note that there are some explanatory texts on larger screens.

plurals
  1. POHiding sub menu with delay in JQuery
    primarykey
    data
    text
    <p>I have a menu with sub menu. when you click on menu item, sub menu will be visible. when mouse leave the menu, sub menu will be hidden after 1 sec. what I want is that if mouse back to menu before 1 sec hiding function terminate.</p> <p>here is what I did:</p> <p><a href="http://jsfiddle.net/CPxTA/" rel="nofollow"><strong>jsFiddle</strong></a></p> <p><strong>HTML</strong></p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;span&gt;Item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item&lt;/span&gt; &lt;ul&gt; &lt;li&gt;&lt;span&gt;Item2&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item2&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item2&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item2&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;&lt;span&gt;Item&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item&lt;/span&gt; &lt;ul&gt; &lt;li&gt;&lt;span&gt;Item3&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item3&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item3&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span&gt;Item3&lt;/span&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p><strong>CSS</strong></p> <pre><code>body,htnl,ul{ padding:0; margin:0; } ul { list-style:none; background:#ddd; overflow:hidden; } li{ float:left; display:block; padding:3px 10px; margin:4px; background:#bbb; } ul ul{ position:absolute; display:none; left:0; } </code></pre> <p><strong>JQuery</strong></p> <pre><code>$("ul li").click(function(){ $(this).find("ul").show(); }).parent().mouseleave(function(){ setTimeout(function(){ $("ul li").find("ul").hide(); },1000); }).parent().mouseenter(function(){ $("ul li").stop(true,true); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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