JQuery implements the return to top function. jquery implements the return to top function.
The code is very simple. There is not much nonsense here. Let's look at the code.
HTML:
<! -- Go to Top --> <div id = "Fixed"> <a id = "goTop" class = "fl" title = "Go Top" href = "javascript :; "> go to the top </a> </div> <! -- Go to Top end -->
CSS:
. Fl {display: block; float: left; width: 50px; height: 50px; text-align: center; background-color: # eaeaea; background-image: url (.. /images/toTop.png );}. fl: hover {background-color: # f48942; background-image: url (.. /images/toTop.png);} # Fixed {position: fixed; _ position: absolute; z-index: 100; bottom: 70px; left: 50%; margin-left: 530px; _ bottom: auto; _ top: expression(document.documentElement.scrollTop+document.doc umentElement. clientHeight-this.offsetHeight-70); width: 50px; text-indent:-40000px; background: # fff}/* top end */
Js:
/* Top setting function */$ (function () {$ (window ). bind ('scroll', {fixedOffsetBottom: parseint('{fixed'}.css ('bottom ')}, function (e) {var scrollTop = $ (window ). scrollTop (); var referFooter =$ ('# footer'); scrollTop> 100? $ ('# GoTop'). show (): $ ('# goTop'). hide (); if (! /Msie 6/I. test (navigator. userAgent) {if ($ (window ). height ()-(referFooter. offset (). top-$ (window ). scrollTop ()> e. data. fixedOffsetBottom) {{('{fixed'}.css ('bottom ', $ (window ). height ()-(referFooter. offset (). top-$ (window ). scrollTop ()} else {response ('{fixed'}.css ('bottom ', e. data. fixedOffsetBottom) }}); $ ('# goTop '). click (function () {$ ('body, html '). stop (). animate ({'scrolltop ': 0, 'duration': 100, 'easing': 'wait-in'}) ;});/* Top-Down Function end */
Articles you may be interested in:
- JQuery animated volume page returns top animation effects (compatible with Chrome)
- Jquery-based return to the top effect (compatible with IE6)
- Returns the jquery implementation code at the top of the Sina Weibo record.
- How does js + JQuery return to the top?
- Code for returning to the top of smart hiding and sliding effects implemented by jQuery
- JQuery's return to the top function is suitable for browsers that do not support js.