title: Stopping "Back to Top Button" before footer
body: <p>I have this code: </p>
  
  <pre><code>        $(function() {
  // cache scroll to top button
  var b = $('#back-top');
  // Hide scroll top button
  b.hide();
  // FadeIn or FadeOut scroll to top button on scroll
  $(window).on('scroll', function(){
      // if you scroll more then 400px then fadein goto top button
      if ($(this).scrollTop() &gt; 500) {
          b.fadeIn();
      // otherwise fadeout button
      } else {
          b.fadeOut();
      }
  
  });
  // Animated smooth go to top
  b.on('click', function(){
      $('html,body').animate({
          scrollTop: 0
      }, 2000 );
      return false;
  });
  $('#back-top').)
  });
  </code></pre>
  
  <p>Everything works really well, BUT I can't find a solution to stop the button scrolling before it hits the footer.:(
  I hope someone here has a solution for my problem!?
  Any help or advice would be very helpful! 
  Thanks!</p>
  
  <p>Update:</p>
  
  <p>well I'm getting there!! 
  I updated the fiddle with the new code: <a href="http://jsfiddle.net/q8DUC/6/" rel="nofollow">http://jsfiddle.net/q8DUC/6/</a> <br />
  I implemented a line that enables the smooth scrolling to every href="#" and its working! <br /> <strong>BUT</strong> I still have the old problem that the back-top element scrolls into the footer! I would apreaciate any ideas or help to make the backtop to stop before the footer! THX!!</p>
  
  <p><br /><br />
  <b>UPDATE 26/10/14:</b></p>
  
  <p>Got a bit further: <a href="http://jsfiddle.net/q8DUC/20/" rel="nofollow">http://jsfiddle.net/q8DUC/20/</a> <br />
  Just don't know how I can avoid the jumping of the button!<br />
  Is there a way to stick the button to the bottom instead the top:0???
  <br /><br />
  As always THANKS for every suggestion or help!</p>