The effect of the implementation is that, when there is a scrollbar is, the scrollbar is not moved or with the top distance is less than how many pixels is, the top button is invisible, when the scroll bar and the top distance is greater than a certain pixel, the return top button appears, implementation click ' Back button ', from the current position back to the position. To refer to jquery.min.js first
<src= "__public__/js/jquery-2.1.4.min.js"></script >
Html:
<id= "Back-to-top" style= "Display:none"> return </> back </> top </ > Division </div>
Css:
#back-to-top{width:25px;position:fixed;Bottom:20px; Right:20px;Border:Solid 1px #ccc;cursor:Pointer;text-align:Center;Color:Red;_top:expression (eval (document.documentelement.scrolltop+ document.documentelement.clientheight-this.offsetheight-(parseint (this.currentstyle.margintop,10) | | 0)-(parseint (this.currentstyle.marginbottom,10) | | 0 ))); }
ls|
JQuery (function ($) { //a jump link appears when the position of the scroll bar is below 20 pixels from the top, otherwise disappears$ (window). Scroll (function(){ if(JQuery (window). scrolltop () >20) {jQuery ("#back-to-top"). FadeIn (1000); } Else{jQuery ("#back-to-top"). FadeOut (1000); } }); //When you click the Jump link, go back to the top position of the pageJQuery ("#back-to-top"). Click (function() {JQuery (' body,html '). Animate ({scrolltop:0},1000); return false; }); });
jquery bottom right corner back to top