Q:

Scroll to the top of the page with jQuery

0

Scroll to the top of the page with jQuery.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>Scroll to the top of the page with jQuery</title>
</head>
<body>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
  <p>jquery</p>
<a href='#top'>Go Top</a>  
</body>
</html>

JavaScript Code :

$("a[href='#top']").click(function() {
  $("html, body").animate({ scrollTop: 0 }, "slow");
  return false;
});

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now