Note that there are some explanatory texts on larger screens.

plurals
  1. POhorizontal jquery menu with subsectons
    primarykey
    data
    text
    <p>I need some help. I've looked everywhere but I do think what i'm looking for is a little unique.</p> <p>I'm trying to make a menu that when you click on a menu option a group of options. That bit I got, i think. what im trying to achieve now is getting it to allow the children of the submenu slide in-between the line of links directly. kind of like an horizontal accordion menu, with the twist of having all the top menu links in a row rather then vertically. </p> <p>the action, click on topmenu item and a submenu(s) links will appear. if a submenu link is clicked, that link with appear the sub-submenu items corresponding to that original link and hiding all but itself and its parents.</p> <p>im not sire if im explaining it right. my head is a little brain-dead from trying to solve this issue all day and im about to cave in.</p> <p>this is an example of what im trying to achieve:</p> <p><img src="https://i.stack.imgur.com/tG4oi.jpg" alt="enter image description here"></p> <p>if you want go here to see what i have done <a href="http://jsfiddle.net/pi_mai/zuU5M/" rel="nofollow noreferrer">http://jsfiddle.net/pi_mai/zuU5M/</a> So i'm trying to make a menu with this HTML code ( i've remove many link items to shorten the code ):</p> <pre><code> &lt;nav&gt; &lt;ul class="topmenu"&gt; &lt;li class="topmenu-item-1"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="topmenu-item-2"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="submenu topmenu-item-1"&gt; &lt;li class="submenu-item-1"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="submenu-item-2"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="subsubmenu submenu-item-1"&gt; &lt;li class="submenu-item-1"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="submenu-item-2"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="submenu topmenu-item-1"&gt; &lt;li class="submenu-item-7"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="submenu-item-8"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="submenu topmenu-item-2"&gt; &lt;li class="submenu-item-1"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="submenu-item-2"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;ul class="submenu topmenu-item-3"&gt; &lt;li class="submenu-item-1"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;li class="submenu-item-2"&gt;&lt;a href="" class="topmenu-link"&gt;top menu&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p>.</p> <pre><code>$('.topmenu &gt; li').on('click',function(){ var itemClass = $(this).attr('class'); console.log(itemClass) $('.submenu').not(this).removeClass('toggle'); $('.submenu.' + itemClass ).toggleClass('toggle'); $('.subsubmenu.toggle').siblings().removeClass('toggle') }); $('.submenu &gt; li').on('click',function(){ var itemClass = $(this).attr('class'); console.log(itemClass) $('.subsubmenu').not(this).removeClass('toggle'); $('.subsubmenu.' + itemClass ).toggleClass('toggle'); }); </code></pre> <p>Can anyone help me? </p> <p>EDIT</p> <p>I think I have the solution, just need to add animation but it's working overall and that to me is fantastic!</p> <pre><code>function menuTap( $this ){ var thisClass = $this.attr('class'); if( $this.parent().hasClass("top-menu") ){ $('.sub-menu.' + thisClass ).animate().toggleClass('hide'); $('.sub-menu' + ':not(.' + thisClass + '), .sub-sub-menu' ).addClass('hide'); }; if( $this.parent().hasClass("sub-menu") ){ console.log( $this.attr('class') + ' li was clicked') $('.sub-sub-menu.' + thisClass ).toggleClass('hide'); $('.sub-sub-menu' + ':not(.' + thisClass + ')' ).addClass('hide'); }; } $('.top-menu li, .sub-menu li').on('click',function(){ menuTap( $(this) ); }); </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