您好,登錄后才能下訂單哦!
=====================js==============
;(function($){
$.extend({
myScrollUp:function(options){
var defaults={
scrollName:"scrollUp",
topDistance:"300",
topSpeed:300,
animation:"slide",
animationInSpeed:200,
animationOutSpeed:200,
scrollText:"回到頂部",
activeOverlay:false
}
<!--覆蓋默認(rèn)值-->
var defaults=$.extend(defaults,options);
var sn="#"+defaults.scrollName,
td=defaults.topDistance,
ts=defaults.topSpeed,
an=defaults.animation,
is=defaults.animationInSpeed,
os=defaults.animationOutSpeed,
st=defaults.scrollText,
ao=defaults.activeOverlay;
/*添加a標(biāo)簽和樣式*/
$("<a/>",{id:defaults.scrollName,title:st,text:st,herf:"#top"}).appendTo("body");
// $(sn).css({"position":"fixed","display":"none","z-index":"123456789"});
if(ao){
$("body").append("<div id='"+defaults.scrollName+"-active'></div>" );
$(sn+"-active").css({"position":"absolute","top":td+"px","width":"100%","border-top":"1px dotted "+ao,"z-index":"2147483647"})
}
/*滾動(dòng)事件*/
$(window).scroll(function(){
if(an==="fade")
$($(window).scrollTop()>td?$(sn).fadeIn(is):$(sn).fadeOut(os));
else if(an==="slide")
$($(window).scrollTop()>td?$(sn).slideDown(is):$(sn).slideUp(os));
else
$($(window).scrollTop()>td?$(sn).show():$(sn).hide());
});
/*點(diǎn)擊*/
$(sn).click(function(event){
$("html, body").animate({scrollTop:0},ts);
return false
})
}
})
})(jQuery);
==================html頁(yè)面引入使用=========================
$.myScrollUp({
scrollName:"scrollUp",
topDistance:"300",
topSpeed:300,
animation:"slide",
animationInSpeed:200,
animationOutSpeed:200,
scrollText:"回到頂部",
activeOverlay:true
});
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。