Html页面加回滚

<div class="top-box">
<img src="~/Content/img/youlink.jpg" width="54" height="60" class="youlink-img" /><br />
<img src="~/Content/img/top.gif" class="top-img" />
</div>



//根据浏览页面的高度,显示回滚标签
$(window).scroll(function () {
if ($(window).scrollTop() >= ($(window).height() - 200)) {
$('.top-box').fadeIn();
}
else {
$('.top-box').fadeOut();
}
});

//点击进行回滚
$(".top-img").on("click", function () {
//动画效果
$('html,body').animate({ scrollTop: 0 }, 500);
});

 

posted @ 2015-08-04 13:40  逍遥帝君  阅读(504)  评论(0编辑  收藏  举报