Situation: google custom search - when you click on the transition to the next page in the search results, the page does not scroll up to the end (it's probably Google’s bug), I try to do it myself using jquery

$(document).ready(function(){ $(".gsc-cursor-page").click(function () { $('html, body').animate({scrollTop:0}, 'fast'); }); }); 

.gsc-cursor-page - div in which the page navigation is located, specifically the page number.

but it completely does not want to do scrolling in this situation, perhaps because Google has its own task when clicking on this div, and my task is completely ignored. Moreover, if you hang an event on the click of any other element (also diva), then everything works fine.

Patient here

  • apparently a miracle will not be .. as always ^ _ ^ - Ozim
  • And if you try to transfer a .colback in .animate() , which will be re-doing the same animation? - Specter
  • and on the fingers can be? I'm not strong at js .. - Ozim
  • something like this: $ (". gsc-cursor-page"). click (function () {$ ('html, body'). animate ({scrollTop: 0}, 'fast', function () {$ ( 'html, body'). animate ({scrollTop: 0};})}}; - Specter
  • No, it did not help. - Ozim

2 answers 2

 $('html, body').animate({scrollTop:0}, 'fast'); 

try changing the selectors. For example:

 $('body') или $('html') 

    I understand: there is a certain div that contains page numbers. These are links that, when clicked, should scroll the page up. This div has the class .gsc-cursor-page . The error is, in my opinion, that the event of clicking on the link inside this diva should be tracked, and not on the div itself, as you have it. Something like this:

    $('div.gsc-cursor-page a').click(function....

    • no, there is no link - stupid div and inside it is text (page number) if you pay attention, at the very bottom there is a "up" button - and so there is the same: div with text inside, with the same div class, and everything works . - Ozim
    • write instead of the animation call console.log ('click is work'); Next, look at the console and check on the click whether this inscription appears in the console (so check if you have at least a click) - Igor Kalamurda