My mobile nav for a website Im making with HTML CSS and BS3, is very basic. but im wanting to disable scrolling of the rest of the body when I toggle the hamburger button.
My issue is that when its turned on, you cant scroll, which is what i want. But when you toggle off the menu, it doesnt work.
heres some of the HTML:
  <!--        mobile nav links-->
              <div class="mob-div-nav">
                <div class="row">
                  <div class="col-xs-12" style="height:100%;">
                  </div>
                </div>
              </div>
      <!--        END Mobile Nav-->
Here is the Js:
  $("#hamburger").on("click", function (event){
  $(".mob-div-nav").slideToggle(500);
  function noscroll() {
  window.scrollTo( 0, 0 );
}
  // add listener to disable scroll
  if ($(".mob-div-nav").css("display") == "block"){
    window.addEventListener('scroll', noscroll);
    } else if ($(".mob-div-nav").css("display") == "none") {
      window.removeEventListener('scroll', noscroll);
    }
});
 
    