I want to know when on click event called the window scroll to top of the document with smooth scrolling behavior. Can anyone help me?
Asked
Active
Viewed 35 times
2 Answers
1
$('html, body').animate({
scrollTop: $("#header").offset().top
}, 500);
where #header
is the top header

Max Njoroge
- 489
- 3
- 21
1
I hope you will get your answer here.
https://www.w3resource.com/jquery-exercises/part1/jquery-practical-exercise-2.php
https://www.geeksforgeeks.org/scroll-to-the-top-of-the-page-using-javascript-jquery/
OR
You can do with this syntex
$("body").scrollTop(0);

Rohit Tagadiya
- 3,373
- 1
- 25
- 25