JQUERY DISPLAY BACK TO TOP LINK BASED ON PAGE HEIGHT


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3. var height = $("#main").height();
  4. if (height > 700) {
  5. $(".top").show();
  6. } else {
  7. $(".top").hide();
  8. }
  9. });
  10. </script>
  11.  
  12. <div id="main" style="border:1px dashed #ccc;">
  13. <p>If content in this div gets higher than 700px, link will show</p>
  14. </div>
  15. <div class="top"><a href="#">Back to top</a></div>

URL: http://www.vagrantradio.com/demos/top_link/index.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.