I am using jQuery with TypeScript and I want to implement a smooth scroll feature. However, when I try to use the $.attr method in jQuery, I encounter an error:
$.attr in jQuery: Property 'attr' does not exist on type 'JQueryStatic'
Can anyone help me troubleshoot this error?
$(document).on('click', 'a[href^="#"]', function (event) {
event.preventDefault();
$('html, body').animate({
scrollTop: $($.attr(this, 'href')).offset().top
}, 500);
});