How to make the page go up when the button is pressed? For example, I have AJAX (loading content without reloading the page), and I need the page to go up when I press a button.

<script type="text/javascript"> jQuery(document).ready(function($) { ??????????????????????? }); </script> <a href="index.php">Ссылка</a> 
  • Why do it on jQuery? If you can just make an anchor? <a href="#"> Top </a> Try it. - Oleg
  • Anchor instantly moves, but not smoothly scrolls. - Suvitruf

2 answers 2

https://jsfiddle.net/vz2wryLb/2/

  • @mountpoint, thanks! - KYRAN

Google is generally lazy, right?

 $(function(){ $(document).scrollTop(0); }); 

I don't work with jQuery, but somehow.

  • @TheDoctor, not working! In my opinion, you need to add a type of a click - KYRAN
  • one
    So this is an example! Here is a working example, I hope you will understand: jsfiddle.net/vz2wryLb/1 - user31688
  • <code> <a href="#"> & uArr; </a> </ code> - also works without any JavaScript scripts - zhenyab
  • @zhenyab, I think the vehicle is not in vain "transparently hinted" that you need to use jQuery, do you guess? - user31688
  • And without jQuery, we can’t breathe. On jQuery, the light came together. I just suggested an alternative, the true Jedi way. But if the questioning adept and jQuery fan, then I, of course, wash my hands. - zhenyab