javascript - Jquery changing class when relative divs active -
so have couple of functions menu trigger (hamburger) opens , closes sidebar menu , in process changes shape 3 lines x (standard) in form of class called active..
here code ....
$(document).ready(function () { var $navtoggle = $('.nav-toggle'); $(".navbtn").click(function () { if($navtoggle.hasclass('active')){ $('#menu').multilevelpushmenu('collapse'); $navtoggle.removeclass('active'); $(this).addclass('active'); } else{ $('#menu').multilevelpushmenu('expand'); $navtoggle.addclass('active'); $(this).removeclass('active'); } }); //allows click on body close menu// $(":not(#menu)").click(function(){ $( '#menu' ).multilevelpushmenu( 'collapse' ); $('.nav-toggle').removeclass('active'); $(this).addclass('active'); }); });
i can't seem "allow click on body" functions work, because getting confused other 2 functions above... can me out ?
assuming have body content wrapped type of container . add click function container.
example.
$(".container").click(function(){ $( '#menu' ).multilevelpushmenu( 'collapse' ); $('.nav-toggle').removeclass('active'); $(this).addclass('active'); });
Comments
Post a Comment