//动态设置侧边栏滚动 $(function () { var offset_top = $('.right_nav').offset().top; //获取右侧导航距离顶部的高度 var begin = 0, end = 0, timer = null; $('.right_nav li:last').hide(); //先将回到顶部隐藏 $(window).scroll(function (evt) { clearinterval(timer); var scroll_top = $(window).scrolltop(); end = offset_top + scroll_top; scroll_top > 100 ? $('.right_nav li:last').fadein() : $('.right_nav li:last').fadeout(); //滚动距离判断是否显示回到顶部 timer = setinterval(function () { //滚动定时器 begin = begin + (end - begin) * 0.2; if (math.round(begin) === end) { clearinterval(timer); } }, 10); }); }); //右侧导航伸缩效果 var right_nav = $(".right_nav"); var temps; $(".right_nav").hover(function () { var thisobj = $(this); temps = settimeout(function () { thisobj.find("li").each(function (i) { var ta = $(this); settimeout(function () { ta.animate({ right: "0" }, 200); }, 50 * i); }); }, 200); }, function () { if (temps) { cleartimeout(temps); } $(this).find("li").each(function (i) { var ta = $(this); settimeout(function () { ta.animate({ right: "-70" }, 200, function () {}); }, 50 * i); }); }); //右侧导航点击事件 $(".right_nav li").each(function (i) { if (i == 0 || i == 1 || i == 2) { $(this).mouseover(function () { $(this).children(".hidebox").stop().fadein(); right_nav.css('overflow', 'visible') }); $(this).mouseout(function () { $(this).children(".hidebox").hide(); right_nav.css('overflow', 'hidden') }); } else if (i == 3) { $(this).click(function () { location.href = 'lxwm.aspx?channel_id=15'; }) } else if (i == 4) { $(this).click(function () { $('body,html').animate({ scrolltop: 0 }, 400); }) } })