2.完成鼠标附上去按钮变化:addClass和removeClass
3.点击之后滑动到顶部:
动画animate({},1500);
4.判断什么时候显示隐藏按钮
$(window).scroll(function(){
if($(document).height() - $(window).height() - $(document).scrolltop() <= 200;){
隐藏按钮代码
}
})
5.参考代码: $(function(){
$(window).scroll(function(){
if($(document).height() - $(window).height() - $(document).scrolltop() <= 200;){
$("#topbtn").show(300).mouseover(function(){
$(this).addClass('current');//设置鼠标移动上去的样式
}).mouseout(function(){
$(this).removeClass('current');
})
}else{$(this).hide(300);//隐藏,也可以用淡入淡出:.fadeOut(300);}
});
$("#topbtn").click(funtion(){
$("body,html").animate({scrollTop:0},1500);//设置滚动条滑动到顶端动画
});
})
