I found a helpful code snippet for adding a scroll to top button on my webpage at the following link:
http://jsfiddle.net/neeklamy/RpPEe/
Although I implemented the code provided, unfortunately, the scroll to top button is not displaying correctly. Here is an excerpt from my webpage's source code:
<!DOCTYPE html>
<html>
<head>
<title>Rough</title>
<style type ="text/css">
.scrollup {
width: 40px;
height: 40px;
position: fixed;
bottom: 50px;
right: 100px;
display: none;
text-indent: -9999px;
background: url('icon_top.png') no-repeat;
background-color: #000;
}
</style>
<script>
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
$('.scrollup').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
});
</script>
</head>
<body>
<h1>Top of the page</h1>
<article style="height: 1000px">
<p style="margin-bottom: 600px">Scroll down the page…</p>
<p>Then click the box.</p>
<a href="#" class="scrollup">Scroll</a>
</article>
</body>
</html>