Closing the menu on link click

Home Forums Porto – Responsive HTML5 Template Closing the menu on link click

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10004933
    HappyMonkey
    Participant

    First off, great theme, thank you! This may seem odd, but I’m using the mega menu for a collection of links that I ajax load into a div on the same page. Everything works as it should, with the exception that the menu stays open after clicking on the link. I then have to move the mouse out of the menu for it to disappear. For the life of me I can’t seem to figure out how to close the menu using javascript after clicking on one of the menu links. Any ideas?


    #10004952
    Support
    Keymaster

    Hello, hum, the problem is that the display of the sub-menu is based on CSS, you would have to make a few changes and add a script for it, something like this:

    (css/custom.css)

    #header nav ul.nav-main li.dropdown:hover > ul {
        display: none;
    }
    
    #header nav ul.nav-main li.dropdown.hover > ul {
        display: block;
    }

    (js/custom.js)

    $('#header li.dropdown').mouseenter(function() {
    	$(this).addClass('hover');
    }).mouseleave(function() {
    	$(this).removeClass('hover');
    });

    Then add a custom event in the link that removes the “hover” class from the parent item via JS, it will make the item to closes.

    Hope it helps.

    Thanks.


Viewing 2 posts - 1 through 2 (of 2 total)

This topic is marked as "RESOLVED" and can not rceive new replies.