Simply Use Following Code To Do That
function goToTop() {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
}
This Is A Simple Exam That Use Scroll Top Function.
<html>
<head>
<title>Easy Code Stuff - Scroll To Top Using JQuery</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
function goToTop() {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
}
</script>
</head>
<body>
<h2>This Is The Top Of The Page</h2>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<p>This is The Long Paragraph<br/>This is The Long Paragraph<br/>
<br/><br/>
<input type="button" value="Go To Top" onclick="goToTop()"/>
</body>
</html>
No comments:
Post a Comment