html
<h2 class="backToTop">back-to-top</h2>
<h2 class="backToTopFix">back-to-top</h2>
css
.backToTopFix{
position:fixed;
top:5px;
display:none;
}
jQuery
// get the distance from .stop to top
var checkIfTop = jQuery(".stop").offset().top;
checkIfTopjQuery(window).scroll(function() {
// if window top is greater than or equal to checkIfTop condition
if(jQuery(window).scrollTop()>=checkIfTop){
jQuery(".backToTop").hide();
jQuery(".backToTopFix").show();
}
else{
jQuery(".backToTop").show();
jQuery(".backToTopFix").hide();
}
});
No comments:
Post a Comment