Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Scroll to top button script that works on mobile devices!

Hi All -

I'm working on a project for myself and I'm trying to add a scroll to top button that works on mobile devices. I've found several jQuery scripts that work on desktop browsers but don't seem to work correctly on mobile devices.

Just some extra info - my project is using Bootstrap 3.

Any suggestions?



Can the button just be a simple link that has an href of "#"? Or does it need to be a script with animation?

Hi Keith -

Thanks for responding. I am looking to add a fade in button that shows up after getting past a certain pixel threshold on scrolling. I'm going to try Nick's answer below.

Thanks again!


1 Answer

Nick Pettit
Nick Pettit
Treehouse Teacher

Hi Matthew Sambrook,

This bit of jQuery will probably do what you're looking for: http://tympanus.net/codrops/2010/01/03/scrolling-to-the-top-and-bottom-with-jquery/

Keep in mind that most mobile browsers allow users to simply tap the menu bar at the top of the screen to scroll back to the top of a webpage, so this might not be a necessary addition.

Hi Nick -

Thanks for the link! I didn't know that you could tap the bottom of the browser to scroll back to the top, good info.