Wednesday, 15 August 2012

javascript - Animating scrolltop event not working -


I'm trying to revive a scrollp action when I return to the top button However, it pulls back to the top without animation, can it be the CSS parameter error?

This script is:

  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "js / jquery.sticky.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Window) .scroll (function () {if ($ (this) .scrollTop ()> 990) {$ ('.schup'). FadeIn (600)} and {$ ('.schup'). FadeOut ( 300)}}); $ ('.schup'). Click (function () {$ ('html, body'). Animate ({scrollTop: 0}, 600); return;}); & Lt; / Script & gt;   
  & lt; Div id = "toparrow" & gt; & Lt; A href = "#" class = "scrollup" & gt; Scroll & lt; / A & gt; & Lt; / Div & gt;   

and CSS element:

  #toparrow {} .scrollup {width: 72px; Height: 45px; Top: 240px; Left: 927px; Status: Completed; Background: url ('../ img / generic / toparrow.png') below; display none; Text Indent: -9999px; }   

and website:

because the button is a href = "#" means that you go to the top section You can use preventDefault to change this browser behavior.

  $ ('. Scrollup'). Click (function (e) {e.preventDefault (); $ ('Html, body'). Animate ({scrollTop: 0}, 600); return;});   

about event.preventDefault :

No comments:

Post a Comment