0

i have this javascript so that when a user is scrolling on the page there will be a small icon to the side that will scroll all the way back up the page rather than manually scrolling. The button shows fine but when i click on it it is not going all the way to the top.

html

<a href="#" class="scrollup">Scroll</a>

Script

$(document).ready(function () {

        $('#main').scroll(function () {
            if ($(this).scrollTop() > 100) {
                $('.scrollup').fadeIn();
            } else {
                $('.scrollup').fadeOut();
            }
        });

        $('.scrollup').click(function () {
            $("html, body, main_container, main").animate({ scrollTop: 0 }, 600);
            return false;
        });

    });
j08691
  • 204,283
  • 31
  • 260
  • 272
Masriyah
  • 2,445
  • 11
  • 49
  • 91
  • 1
    http://stackoverflow.com/questions/832860/how-to-scroll-the-window-using-jquery-scrollto-function – kroehre Apr 19 '13 at 18:39

1 Answers1

1

problem is in the selectors, you are missing either # id selector or . class selector, to me it seems id:

change this:

$("html, body, main_container, main")

to this and see if it helps:

$("html, body, #main_container, #main")
//-------------^----------------^--------these selector notations
Jai
  • 74,255
  • 12
  • 74
  • 103