jQuery: Scroll to the Top of a Page

jQuery-logoMy current project requires me to split up a particularly long survey into chunks, allowing a survey taker to only submit those chunks that he/she feels like submitting and ignoring the rest.

Now to be all spiffy I simply fade out the affected chunk once the user clicks submit and then throw back a growl notification at him thanking him for his submission. However, it was at this point that I hit a small snag in that the growl works visually best if you scroll all the way back up to the top of the page and thus I set about looking on the web for a decent scrollTo jQuery plugin as quite simply I don’t have the time to whip up my own.

All of which brought to me the discovery of Ariel Flesler’s nifty jQuery.ScrollTo plugin which you can read more about (and grab) here: http://flesler.blogspot.com/2007/10/jqueryscrollto.html

Add the link to the plugin in your page and hey presto, when you want to scroll the screen all the way up, simply do this:

$.scrollTo(0);

 Nifty.

Related Posts :

About Craig Lotter

Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under the Funakoshi karate style and for the most part, simply enjoys life with his amazing wife and daughter. Oh, and he draws ever now and then too.
This entry was posted in Technology & Code, Tutorials and tagged , , , , . Bookmark the permalink.
  • http://pbx-phone-system.info/ Christine

    Very nice article. I thought to let you know that you website wasn’tt getting displayed properly on minimo mobile web browser on my pda.

    Have a nice time…sorry for typing mistake

  • http://pbx-phone-system.info/ Christine

    Very nice article. I thought to let you know that you website wasn’tt getting displayed properly on minimo mobile web browser on my pda.

    Have a nice time…sorry for typing mistake