Note that there are some explanatory texts on larger screens.

plurals
  1. POActivate JQuery menu on Hover or Click
    primarykey
    data
    text
    <p>My goal is to animate a JQuery menu to respond when hovered or clicked. Using the HoverIntent plugin the following code is working as intended to hover. But how do I add a click event while maintaining a user friendly menu? While planning how to write this I have considered adding a delay to the hover event when a menu item is clicked, however I am unsure how practical that implementation would be. How would I add the click event to the following code?</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { function show() { var menu = $(this); menu.children(".options").slideDown(); } function hide() { var menu = $(this); menu.children(".options").slideUp(); } $(".menuHeader").hoverIntent({ sensitivity: 3, interval: 50, over: show, timeout: 300, out: hide }); }); </code></pre> <p></p> <pre><code>&lt;div id="SideMenu"&gt; &lt;div id="aMenu" class="menuHeader"&gt; &lt;h2&gt;Menu A&lt;/h2&gt; &lt;ul class="options" &gt; &lt;li&gt;&lt;a href=""&gt;Option a1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option a2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option a3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="bMenu" class="menuHeader"&gt; &lt;h2&gt;Menu B&lt;/h2&gt; &lt;ul class="options" &gt; &lt;li&gt;&lt;a href=""&gt;Option b1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option b2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option b3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;div id="cMenu" class="menuHeader"&gt; &lt;h2&gt;Menu C&lt;/h2&gt; &lt;ul class="options" &gt; &lt;li&gt;&lt;a href=""&gt;Option c1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option c2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href=""&gt;Option c3&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Sorry about the formatting of the code, and thank you for your help.</p>
    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.
 

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