Click Back to top, three ways
1, this method jquery use normal, zepto use no animation
// Zepto No animation $ ("body"). Animate ({scrolltop:0}, $)//Zepto use $ ("body"). ScrollTop ( 0);
2, this method jquery use normal, zepto use no animation
Window.scrollto (0,0);
3, Zepto use can have animation
functiongotop (acceleration, time) {acceleration= Acceleration | | 0.1; time= Time | | 16;varX1 = 0;varY1 = 0;varx2 = 0;vary2 = 0;varx3 = 0;varY3 = 0;if(document.documentelement) {x1= Document.documentElement.scrollLeft | | 0; Y1= Document.documentElement.scrollTop | | 0;}if(document.body) {x2= Document.body.scrollLeft | | 0; Y2= Document.body.scrollTop | | 0;}varx3 = WINDOW.SCROLLX | | 0;varY3 = window.scrolly | | 0;//horizontal distance from scroll bar to top of pagevarx =Math.max (x1, Math.max (x2, x3));//vertical distance from scroll bar to top of pagevary =Math.max (y1, Math.max (y2, y3));//scrolling distance = current distance/speed, because the distance is smaller, the speed is greater than 1 of the number, so the rolling distance will be more and more smallvarSpeed = 1 +Acceleration;window.scrollto (Math.floor (x/speed), Math.floor (Y/Speed ));//if the distance is nonzero, continue calling the iteration functionif(X > 0 | | y > 0) {varInvokefunction = "Gotop (" + Acceleration + "," + Time + ")"; Window.settimeout (invokefunction, Time);}} $(". Fix_go_top"). On ("click",function() { //$ ("body"). ScrollTop (0); //Window.scrollto (0,0);gotop ();});
Returns the top 3 Chinese method (solves the effect that the mobile side uses zepto without sliding)