Hey there, I am working on creating a one-page scroll navigation with some basic javascript to add a smooth animation effect that takes 1 second as it scrolls to the desired section. However, I seem to be experiencing an issue where it's not functioning correctly. Any suggestions or ideas from anyone?
Html
<ul class="header-nav">
<li><a id="home" href="#home-View">Home</a></li>
<li><a id="about" href="#about-View">About</a></li>
<li><a href="#">Blog</a></li>
<li><a id="contact" href="#contact-View">Contact</a></li>
</ul>
Javascript
$(document).ready(function() {
// adding click listeners to each anchor tag
setBindings();
});
function setBindings() {
$(".header-nav a").click(function(e) {
// prevent default behavior for anchor tags
e.preventDefault();
var sectionID = e.currentTarget.id + "Section";
$("html body").animate({
scrollTop: $("#" + sectionID).offset().top
}, 1000)
alert("sdf");
})
}