$(document).ready(function(){
$("a").on('click', function(event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 1500)
}
});
});
window.addEventListener('DOMContentLoaded', () => {
const links = document.querySelectorAll('a');
links.forEach(link => {
link.addEventListener('click', event => {
if (link.hash !== '') {
event.preventDefault();
const target = document.querySelector(link.hash);
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
}
});
});
});
html { scroll-behavior: smooth; }
достаточно будет.