Just place this code anywhere after including jQuery library. This helps the user scroll to the ‘element’ id in href=”#element”.
$(function () {
/* Slide to # location with animation */
$(document).on('click', 'a[href^="#"]', function (event) {
event.preventDefault();
$('html, body').animate({
scrollTop: $($.attr(this, 'href')).offset().top
}, 500);
});
/* Slide to # location with animation */
});
You must be logged in to post a comment.