Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to hide a menu on anything but a click on the menu
    primarykey
    data
    text
    <p>I have a link which is a persons username. When you click it, a little flyout window (an unordered list) appears. I'm trying to make it so:</p> <ol> <li>Clicking on the persons username toggles the flyout ul with fadein/out</li> <li>If you click to show the flyout, and click ON the ul, it doesnt disappear</li> <li>if you click on the body anywhere except the flyout, it disappears</li> </ol> <p>This is what I have so far but I'm basically just fooling myself into thinking I know what I'm doing :(</p> <pre><code>$(document).ready(function() { $('.flyout h3 a').click(function() { var flyout = $('.flyout ul'); flyout.fadeToggle(80,function() { if ( flyout.is(':visible') ) { console.log('visible'); $(document).on('click',function(e) { flyout.fadeOut(80); e.stopPropagation(); }); } else { $(document).off('click'); } }); }); }); </code></pre> <p>html:</p> <pre><code>&lt;div class="flyout"&gt; &lt;h3&gt;Welcome back, &lt;a href="#"&gt;Dogbreath&lt;/a&gt;&lt;img src="img/down-arrow.png" alt="dropdown"&gt;&lt;/h3&gt; &lt;div class="menu"&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span class="icon"&gt;&amp;#128101;&lt;/span&gt;Users&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span class="icon"&gt;&amp;#128360;&lt;/span&gt;Groups&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span class="icon"&gt;&amp;#9881;&lt;/span&gt;Configuration&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;&lt;span class="icon"&gt;&amp;#59201;&lt;/span&gt;Logout&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </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