I'm trying to get the navigation bar to push down the page content when opened on the mobile site.
I have a click event listener, plus a toggle function, and an if statement inside the event listener.
Is there any reason the if statement isn't running properly? I noticed the 'in' class isn't actually being toggled; rather, the display is being toggled between 'block' and 'none'. Right now, the content shifts down when the menu is opened, but doesn't shift back up when it's closed. Thanks!
$('.navbar-toggle').click(function(event) {
$('.navbar-collapse').toggle('in');
if ($(".navbar-collapse").is(":hidden")) {
$('.content-below').css('margin-top','0px');
}
else if ($(".navbar-collapse").is(":visible")) {
$('.content-below').css('margin-top','200px');
}
});
EDIT:
I got the .toggle('in') portion from the last answer in this question: Bootstrap 3 collapsed menu doesn't close on click
Perhaps he meant to use .toggleClass.