1

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?

Devi
  • 71
  • 2
  • 1
    Does this answer your question? [How to scroll to top of page with JavaScript/jQuery?](https://stackoverflow.com/questions/4210798/how-to-scroll-to-top-of-page-with-javascript-jquery) – Hitesh Tripathi Dec 04 '20 at 06:52

2 Answers2

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