Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery dropdown variable height
    primarykey
    data
    text
    <p>So I want to create a dropdown div menu similar to that on starbucks. My initial menu is a simple UL with links, but no second tear lists like a normal dropdown. I have Jquery to handle the hover on the links and to show a div with the corresponding class. Ie hover over link with id 'blog' .. show div with class blog. This works pretty well, the problem is with the slideUp slideDown transitions. Instead of just changing height and showing the new menu (So if div1 has a height of 100px , div2 a height of 200px ... instead of the just changing the height (like on starbucks) my transition slides all the way up, and then back down to the new height.</p> <p>How could I have it so the height would just slide up or down to the new height... and then when the hover leaves it slides all the way up. </p> <p>Currently I have a container div and the specific content divs in this. The container div slides down and the content divs just hide and show when needed.</p> <pre><code> &lt;script&gt; $('#menu a').hover(function(){ var id =(this.id); switch(id) { case 'blog': $('.blog').show(); $('#dropdown').slideDown(); break; case 'videos': $('.videos').show(); $('#dropdown').slideDown(); break; case 'tutorials': $('.tutorials').show(); $('#dropdown').slideDown(); break; }; }, function(){ $('#dropdown').slideUp(); $('.ddmenu').hide(); }); &lt;/script&gt; </code></pre> <p>-------------FIXED</p> <p>Fixed it. Well hacked it. I decided to use a .hover over the menu container first and on hover out it animates the height to 0... inside the however function is nothing which seems a bit wasteful but using .mouseout didn't work :/ </p> <p>heres the code: </p> <pre><code> &lt;script&gt; $('#menu ').hover(function(){ }, function(){ $('#dropdown').stop().animate({height:0},200); }); $('#menu a').hover(function(){ var id =(this.id); switch(id) { case 'blog': $('#dropdown').stop().animate({height:200},300); $('.blog').show(); break; case 'videos': $('#dropdown').stop().animate({height:100},300); $('.videos').show(); break; case 'tutorials': $('#dropdown').stop().animate({height:300},300); $('.tutorials').show(); break; case 'none': $('#dropdown').stop().animate({height:0},300); $('.ddmenu').hide(); break; }; }, function(){ $('.ddmenu').hide(); }); &lt;/script&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.
    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