Revision: 31036
Updated Code
at August 27, 2010 20:34 by jiewmeng
Updated Code
// javascript
$(function() {
$window = $(window);
$link = $("#scrollToTop"); // your link to show when user scrolls down
$link.click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow"); // this is the gist of the script, scroll to top (scrollTop: 0)
});
$window.scroll(function() {
if ($window.scrollTop() <= 0) {
$link.fadeOut("fast");
} else {
$link.fadeIn("fast");
}
})
// css
#scrollToTop:link,
#scrollToTop:visited {
display: none;
position: fixed;
top: 15px;
right: 15px;
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
text-decoration: none;
background: #ccc;
color: #333;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
Revision: 31035
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 27, 2010 20:26 by jiewmeng
Initial Code
$(function() {
$window = $(window);
$link = $("#scrollToTop"); // your link to show when user scrolls down
$link.click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow"); // this is the gist of the script, scroll to top (scrollTop: 0)
});
$window.scroll(function() {
if ($window.scrollTop() <= 0) {
$link.fadeOut("fast");
} else {
$link.fadeIn("fast");
}
})
Initial URL
Initial Description
Initial Title
jQuery: Scroll To Top
Initial Tags
jquery
Initial Language
JavaScript