Self-writing jquery Web page back to the top effect, fade icon, reference JS file can be

Source: Internet
Author: User

Well, come in development requirements, when the content of the Web page chicken, the user needs to have a button quickly back to the top, instead of rolling the pulley himself ~

Originally thought more difficult to say, because the above requirements all with JS to achieve, which page reference, which page is displayed.

So, Ben Dick to try to write the next, hmm, did not find, quite easy to say ~ ~


Fart I will soon put, directly on the code, fart put more into a excrement ~ ~ Ah, sin, Amitabha, amen ~ ~


$ (function () {var $btn _top = $ (' <a id= "scrolltop" ></a> '); $ BTN_TOP.CSS ("Display", "none"), $btn _top.css ("width", "40px"), $btn _top.css ("height", "40px"), $btn _top.css (" Position "," fixed "), $btn _top.css (" Right "," 20px "), $btn _top.css (" Bottom "," 100px "), $btn _top.css (" Z-index "," 990 "); $ ("Body"). Append ($btn _top); $ ("body"). On ("click", "#scrollTop", function () {$ ("html,body"). Animate ({scrolltop:0}, " Slow ");}); if ($ (window). scrolltop () >) {$ ("#scrollTop"). FadeIn (600);} $ (window). Scroll (function () {if (window). scrolltop () >) {$ ("#scrollTop"). FadeIn (600);} else{$ ("#scrollTop"). FadeOut (600);}});

Look for a picture of yourself, I use the absolute path "css/web/images/scrolltop.png"

Change the size directly on lines fourth and fifth, which avoids adding cat tags to the page ~ ~ (>^ω^<) Meow ~ ~ ~

Save into a JS file, direct reference, which pain to use, who knows who use ~ ~ ~


There are exchanges please add qq:1740437, welcome advice ~ ~

Also seek the legendary antique hobby small partner, as well as folk music hobby small partner, or shoot video micro movie Small Partner ~ ~


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.