Created
July 5, 2016 13:38
-
-
Save aislam23/7a8f694f4db794a1b53930a780d914b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$("#menu").on("click","a", function (event) { | |
//отменяем стандартную обработку нажатия по ссылке | |
event.preventDefault(); | |
//забираем идентификатор бока с атрибута href | |
var id = $(this).attr('href'), | |
//узнаем высоту от начала страницы до блока на который ссылается якорь | |
top = $(id).offset().top; | |
//анимируем переход на расстояние - top за 1500 мс | |
$('body,html').animate({scrollTop: top}, 1500); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment