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):

  1. i click given menu item

  2. window scrolls corresponding menu item section

  3. 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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -