-1

From this answer, I have the following after my <body> tag:

<a id="Pagetop"></a>

In my footer, I have:

<script>
    jQuery(document).ready(function () {
        jQuery(".pgtop").click(function () {
            jQuery('html, body').animate({
                scrollTop: jQuery("#Pagetop").offset().top
            }, 1000);
        });
    });
</script>
<p class="pgtop"><img src=".../images/up-arrow.png" alt ="Go to top of page" title ="Go to top of page" width="30" height="auto" border = "0" ></p>

This code works on this site, but the same code does not work on this site.

Can you please see why the up arrow doesn't scroll up on the 2nd site?

The element in question is the up arrow in the bottom right corner of the window.

Help appreciated.

Steve
  • 2,066
  • 13
  • 60
  • 115
  • 1
    It works when `html` doesn't have `overflow-y: scroll;` CSS property. I wish I could explain but I dunno why either... – Jacob Goh May 24 '18 at 02:41
  • That's good enough for me @JacobGoh, add an answer and I'll accept it. Cheers. – Steve May 24 '18 at 02:48

1 Answers1

0

It works when html doesn't have overflow-y: scroll; CSS property.

I wish I could explain but I dunno why either...

Jacob Goh
  • 19,800
  • 5
  • 53
  • 73
  • Hi Jacob, can you see why the scroll up arrow doesn't work on [this site](http://digital.staging.insightdesign.com.au/) after I removed `overflow-y: scroll;` from `html`? – Steve May 24 '18 at 03:04
  • @Steve It works when i executed `jQuery('html, body').animate({ scrollTop: 0 }, 1000);` in the console. – Jacob Goh May 24 '18 at 03:09
  • Thanks Jacob, I replaced the jQuery code with your new code on [that site](http://digital.staging.insightdesign.com.au/) but it doesn't fire when `.pgtop` is clicked on. (line 1314 is where the jQuery is) – Steve May 24 '18 at 03:46