Created
January 22, 2013 18:35
-
-
Save motorcitymobi/4597091 to your computer and use it in GitHub Desktop.
Scroll to Top
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JS: | |
//Scroll to Top | |
$(function() { | |
jQuery(window).scroll(function() { | |
if(jQuery(this).scrollTop() > 150) { | |
jQuery('.up').fadeIn(); | |
} else { | |
jQuery('.up').fadeOut(); | |
} | |
}); | |
}); | |
$('.up').live('click', function() { | |
$('html, body').animate({scrollTop: '0'}, 200); | |
}); | |
HTML: | |
<a href="#wrap" class="up" style="display: block; ">scroll to top</a> | |
CSS: | |
a.up { | |
background: url(http://mcmdemos.com/veracruz/wp-content/themes/veracruz/library/images/totop.png) no-repeat scroll 0 0; | |
width: 39px; | |
height: 42px; | |
position: fixed; | |
bottom: 0; | |
right: 0; | |
text-indent: -9999px; | |
z-index: 9999; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment