jquery implements a fade-back top button

Source: Internet
Author: User

The effect is as follows:

The HTML and CSS code for the button are as follows.

<id= "Gotop">    <class= "fa Fa-chevron-up "></i></div> 

I label <i class= "FA fa-chevron-up" ></i> use the font awesome,400 multiple icons (including QQ, Weibo) as long as 30KB, can be infinitely enlarged, do not need JS, very??。

The button gotop is fixed to the lower right corner of the screen and hidden.

#gotop{position:fixed; Right:10px;Bottom:12%;Z-index:666;Display:None;width:40px;Height:40px;font-size:30px;Line-height:40px;text-align:Center;Color:#fff;Background-color:#21759b;Border-radius:2px;cursor:Pointer;}#gotop: Hover{Background-color:#195a84;}

The JQ code is as follows, the upper part detects the scroll bar position display and hides the Gotop button, and the lower half clicks the button and then the sleek back to the top.

1$(function () {
2 //Save Gotop Button3 varGotop = $ ("#gotop");4 //detects scroll bar position, above 600 back top button display5$ (window). Scroll (function () {6 Console.log ($ (window). scrolltop ());7 if($ (window). scrolltop () > 600) {8Gotop.fadein (1000);9 }Ten Else { OneGotop.fadeout (1000); A } - });
- //gotop button Click, rounded back to the top scrolltop:0 represents the time when the scrollbar 0,800 (MS) represents. theGotop.click (function () { -$ (' body,html '). Animate ({scrolltop:0}, 800); - });
+});

No special effects of the button can see my blog in the lower right corner, the blog Park application JS permissions failed??。

jquery implements a fade-back top button

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.