javascript - jQUery --> hash changing after clicking given menu item -
how make url change hash after clicking given menu item ? (description below shows how want work):
i click given menu item
window scrolls corresponding menu item section
url adress changing hash corresponding clicked menu item hash
this jsfiddle https://jsfiddle.net/d1abevro/5/
i need place following code snipets code below change hash:
var target = this.hash; $target = $(target); location.hash = target;
this code need place snipets somewhere (i tried no avail):
$(document).on("click.menulinkevent", "a.c-main-menu__link:not(a.c-main-menu__link[href='#main-header'])", function(event) { event.preventdefault(); $('html,body').animate({ scrolltop: $($.attr(this, 'href')).offset().top - 56 }, 800); $('.c-main-menu ul').slidetoggle(); });
when try place snipets noticed strange behavior mobile menu (max-width 480 breakpoint).
Comments
Post a Comment