jquery bottom right corner back to top

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.