Skip to content

Instantly share code, notes, and snippets.

@sioniks
Forked from kovaldn/Javascript: scrollto().js
Created July 10, 2017 14:14
Show Gist options
  • Save sioniks/961009e884d8dae56cca39e324ac82bf to your computer and use it in GitHub Desktop.
Save sioniks/961009e884d8dae56cca39e324ac82bf to your computer and use it in GitHub Desktop.
Javascript: scrollto()
(function () {
jQuery('#top_menu li a').on('click', function(){
var item = $(this).parent().attr('class'),
tar = $(this).attr('data');
$("html, body").animate({ scrollTop: jQuery(tar).offset().top }, 1000);
});
})()
// <li class="item-0"><a href="#begin" data=".header1" class="root-item">В начало</a></li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment