The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Minor jQuery Dropdown Menu Issue [Beginner]

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #26429

    Hey guys,

    I am developing a dropdown menu using jQuery (I’m still a beginner). Basically, this is what I am having trouble with:

    When I hover my mouse over "", the menu slides down as it should. But, when I try to click on or just hover on the menus that dropped down, the menu slides back up. Basically, the script I pasted below says this (the incorrect approach):

    "Hover over, drop the menu down. When someone hovers off, collapse it."

    And what i want to happen is someone hovers over and they move their mouse down to be able to click the content in the dropdown menu. But, when they hover their mouse off of the menu, it slides back up.

    I hope I was clear enough! Here’s the code:

    $(document).ready(function() {
    $(‘’).mouseover(function() {
    }).mouseout(function() {

    I am just not sure how to change this code to how I want, but I know what I want it to do. Any help is very appreciated. Thanks!


    Hi Alex,

    I have the exact same problem – so must thousands of others and it’s amazing with it being such a common problem that there aren’t a bunch of video tutorials out there telling us how to solve it. My problem is worse because I’m using sprites as well. And I don’t want to use a plugin – I want to understand how to do it myself.

    What I tried was to add a function so when you mouseover the dropdown, it shows until mouseout. That way, as you mouse from the top level button to the drop down, it stays showing until you mouseout. The snag then is that if you mouseover the dropdown without going to the top level button first, it still shows, which is not what you want.

    I’m wondering if this is actually more advanced than we realise and maybe we need an ‘if’ statement or something of the sort.

    Somebody please help!



    Here is a link to an example page here on css-tricks, that shows how to achieleve one of the most simply jquery dropdowns.

    The approach is actually intuitive, even though at first it may seem a little daunting.

    Basically, the menus are created and positioned with CSS, then the drop menus are hidden, and shown on a hover event.

    Here is just the jQuery for quick reference.


    $(“ul.dropdown li”).hover(function(){

    $(‘ul:first’,this).css(‘visibility’, ‘visible’);

    }, function(){

    $(‘ul:first’,this).css(‘visibility’, ‘hidden’);


    $(“ul.dropdown li ul li:has(ul)”).find(“a:first”).append(” » “);


    I haven’t had a chance to test it, but I imagine that if you could pretty easily convert it to a show/hide for some animation.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.