I am trying to add a scroll function to my landing page so that when the navi bar link is clicked, it smoothly scrolls to the section. instead of CSS, I should use JS, 'addEventListener','preventDefault' and ''scrollIntoView()
to achieve this. I've been trying and trying for days, it just dosen't work, please help me!
PS: I have fixed this problem, thank you you guys
function topFunction() {
document.body.scrollTo({
top: 0,
behavior: "smooth"
});
document.documentElement.scrollTo({
top: 0,
behavior: "smooth"
});
}