Add a smooth scroll effect to an anchor with this simple jQuery snippet.
You need to define a link and then an item with the anchor ID.
In the example below it uses a class to identify the link. You could remove it or change it to your needs.
$(document).ready(function() {
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 500,
easing: "swing"
});
return false;
});
});
$("a.topLink").click(function() {
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top + "px"
}, {
duration: 500,
easing: "swing"
});
return false;
});
});
Found it here.
No comments
Post a Comment