Posted By

vagrantradio on 02/16/10


Tagged

resize link jquery document height body backtotop


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

pauloc
bostonbasso


JQUERY DISPLAY BACK TO TOP LINK BASED ON PAGE HEIGHT


 / Published in: jQuery
 

URL: http://www.vagrantradio.com/demos/top_link/index.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>

Report this snippet  

You need to login to post a comment.