Skip to content

Instantly share code, notes, and snippets.

@jackabox
Created July 6, 2013 11:18
Show Gist options
  • Save jackabox/5939617 to your computer and use it in GitHub Desktop.
Save jackabox/5939617 to your computer and use it in GitHub Desktop.
Fadein Anchor Button with jQuery
<body id="top">
#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 */
}
$(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