I have problem with next/prev Buttons in Pagination. If user clicks button, it reloads the page (i think) in Ajax at the current page scroll position. Is there any method to force the reload jump to top of page?

  • I'm voting to close this question as off-topic because the question does not belong to Magento (in my opinion). Please explain a bit more if you think that your question is valid for this site. – Mohit Kumar Arora Mar 12 '19 at 11:03
  • Because why? If have this problem in Magento2 pagination. Why should it be off-topic? Normal JS solutions doesnt work. I think, thats a M2 problem... – Marcel Mar 12 '19 at 12:59
  • Could be closed/deleted. Its a fault from an extension. – Marcel Mar 12 '19 at 13:38

You can do it by using jquery, add the following script in phtml file.

 require(['jquery', 'jquery/ui'], function($){
  $(".class of your nav button").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");

use your nav button class like $(".nav_btn")


you can use following code in success event of ajax

 $("html, body").animate({ scrollTop: 0 }, "slow");

or make a function and call the function on click of the button


function movetotop(){
     require(['jquery', 'jquery/ui'], function($){

      $("html, body").animate({ scrollTop: 0 }, "slow");

and call this function like <a class ="nav_btn" href="#" onclick="movetotop()" ></a>

write the script outside of the file that is updating on ajax request

  • Good answer. +1 – Shoaib Munir Mar 12 '19 at 10:19
  • I use this (2 pagination at top and bottom), but it only works for the 1st time .require(['jquery', 'jquery/ui'], function($){ $("ul.pages-items a").each(function(index) { $(this).click(function() { $("html, body").animate({ scrollTop: 0 }, "slow"); }); }); }); – Marcel Mar 12 '19 at 12:45
  • then make a function and write the script in it and call the function on click of the button – Waqar Mar 13 '19 at 6:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.