Search code examples
jquerymenuzurb-foundationmenubar

How to close expanded mobile top bar in Foundation via jQuery?


I'm wondering if there is someway to close the expanded topbar in Foundation on click on one of the items? I guess I'm looking for something to put in the center of this:

$('#some-menu-item').click(function() {
    //some function to collapse the menu
});

Solution

  • Figured it out by lifting lines 174-176 of Foundation's topbar.js.

    $('#some-menu-item').click(function() {
        $('.top-bar, [data-topbar]').css('height', '').removeClass('expanded');
    });