jQuery回到头部
2015-04-03
JQuery
1055
var GotoTop = {
setPos:function(width){
var win = $(window);
var win_width = $(window).width();
$(\"#backToTop\").css({
left: parseInt(win_width - (win_width-width)/2)+2,
bottom:150
});
var GotoTop = { setPos:function(width){ var win = $(window); var win_width = $(window).width(); $("#backToTop").css({ left: parseInt(win_width - (win_width-width)/2)+2, bottom:150 }); }, bind:function(){ $("#backToTop").click(function(){ //$("html,body").scrollTop(0); $("html,body").animate({ scrollTop: 0 },240); }); $(window).scroll(function(){ if($(document).scrollTop() > 500){ $("#backToTop").css("display","block"); }else{ $("#backToTop").css("display","none"); } }); }, init:function(width){ $('').appendTo("body"); GotoTop.setPos(width); $(window).resize(function(){ GotoTop.setPos(width); }); GotoTop.bind(); } }; //返顶效果 $(function(){ GotoTop.init(960); });
很赞哦! (0)
相关文章
文章评论
-
-
-
0条评论