Created
November 18, 2012 06:32
-
-
Save rawaludin/4103884 to your computer and use it in GitHub Desktop.
jquery: toTop watcher
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
<script type="text/javascript"> | |
<!--//--><![CDATA[//><!-- | |
jQuery(document).ready(function($) { | |
$(window).scroll(function() { | |
if($(this).scrollTop() != 0) { | |
$("#toTop").fadeIn(); | |
} else { | |
$("#toTop").fadeOut(); | |
} | |
}); | |
$("#toTop").click(function() { | |
$("body,html").animate({scrollTop:0},800); | |
}); | |
}); | |
//--><!]]> | |
</script> | |
CSS: | |
#toTop { | |
background: url("images/backtotop-arrow.png") no-repeat scroll 0% 0% transparent; | |
width: 51px; | |
height: 50px; | |
position: fixed; | |
cursor: pointer; | |
bottom: 60px; | |
right: 10px; | |
display: none; | |
z-index: 100; | |
opacity: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment