Created
July 6, 2013 11:18
-
-
Save jackabox/5939617 to your computer and use it in GitHub Desktop.
Fadein Anchor Button with jQuery
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
<body id="top"> |
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
#toTop { | |
position: fixed; /* Set the position to fixed */ | |
bottom: 20px; /* Move the div 20px from the bottom */ | |
right: 50%; /* Move the div 50% from the right */ | |
margin-right: -500px; /* Move the div back by %px (usually half the width of the div) */ | |
display: none; /* set to display none initially */ | |
} |
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
$(window).scroll( function(){ | |
if($(window).scrollTop()>200){ | |
$("#toTop").fadeIn(); | |
} else { | |
$("#toTop").fadeOut(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment