Note that there are some explanatory texts on larger screens.

plurals
  1. POStop DIV scrolling once it reaches the footer (another DIV)
    primarykey
    data
    text
    <p>I have a "back to top" button that appears when the user scrolls down the page.<br /> With some help I have managed to implement these functions in the code below: <strong>fade in</strong> at certain point after scrolling down, <strong>animated scroll</strong> back to top and animated scrolling to all href="#" links of the page. </p> <pre><code> $('a[href^="#"]').on('click',function (e) { e.preventDefault(); var target = this.hash, $target = $(target); $('html, body').stop().animate({ 'scrollTop': $target.offset().top }, 800, 'swing', function () { window.location.hash = target; }); }); var $win = $(window); $win.scroll(function () { if ($win.scrollTop() &gt; 300) { b.fadeIn(); console.log("fadding in") } else { b.fadeOut(); } }); }); </code></pre> <p>Here is a working exsample: <a href="http://jsfiddle.net/q8DUC/8/" rel="nofollow">http://jsfiddle.net/q8DUC/8/</a></p> <p>My problem is that the button scrolls into the footer of the page... Basically the "back to top" should stop 30px above the "footer" DIV. But I can't find a way to accomplish that. I've looked around but haven't found anything that worked with the existing code. </p> <p>Thanks for any help or suggestions! </p> <p><b>UPDATE:</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>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload