How to scroll to specific element using jquery?

  Kiến thức lập trình

How to scroll on specific element using jquery?

What I’ve tried is this

$("html,body").animate({scrollTop: $(".highlights").offset().top - $("html,body").offset().top + $("html,body").scrollTop(), scrollLeft: 0},300);

It works, but it cannot freely scroll up and down. So I am looking for something that scrolls on a specific element and still allows the user to continue scrolling up or down as usual.

LEAVE A COMMENT