Skip to content

Instantly share code, notes, and snippets.

@dnikonov
Created March 27, 2014 05:21
Show Gist options
  • Save dnikonov/9800861 to your computer and use it in GitHub Desktop.
Save dnikonov/9800861 to your computer and use it in GitHub Desktop.
JS: anchor
// прокрутка на все якоря (#) на странице
$('a[href^="#"]').click(function(event){
event.preventDefault();
var h = $(this).attr('href');
var to = $('a[name=' + h.substr(1) + ']');
$('html, body').stop().animate({
'scrollTop': to.offset().top
}, 250);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment