Created
December 17, 2017 20:18
-
-
Save shehabkhan013/697605bcca3c2b14044af95338b5b265 to your computer and use it in GitHub Desktop.
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
function scrollToTop($topClass){ | |
var top_0 = {scrollTop:0}; | |
var topClass = $($topClass); | |
topClass.on("click" , function(e){ | |
$("html,body").animate(top_0,1000); | |
return false; | |
}); | |
$(window).scroll(function(){ | |
if($(this).scrollTop() > 400) { | |
topClass.fadeIn(500); | |
} | |
else { | |
topClass.fadeOut(500); | |
} | |
}); | |
} | |
scrollToTop('.scrolltotop i'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment