Created
November 18, 2015 12:28
-
-
Save endymion1818/7b767b16e333a9a12aa1 to your computer and use it in GitHub Desktop.
JavaScript for a back To Top button scrolling nicely
This file contains 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
$('.backtotop').click(function () { | |
$("html, body").animate({ | |
scrollTop: 0 | |
}, 600); | |
return false; | |
});; $(document).scroll(function(){ | |
$('.navbar').toggleClass('scrolled', $(this).scrollTop() > 1); | |
$('.backtotop').toggleClass('scrolled', $(this).scrollTop() > 1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment