$(function() { $('.backTop').click(function(event) { $('html,body').stop().animate({ 'scrollTop': 0 }, 500); }); }); $(window).scroll(function() { // 滚动条距离顶部的距离 大于 200px时 if ($(window).scrollTop() >= 100) { $(".sideBar").fadeIn(1000); // 开始淡入 } else { $(".sideBar").stop(true, true).fadeOut(1000); // 如果小于等于 200 淡出 } });