// 懒人图库 搜集整理 www.lanrentuku.com (function ($) { $(function () { nav(); //顶部导航 sideSlider(); //左侧竖导航 }); function nav() { var $liCur = $(".nav-box>ul>li.cur"), curP = $liCur.position().left, curW = $liCur.outerWidth(true), $slider = $(".nav-line"), $targetEle = $(".nav-box>ul>li:not('.last')"), $navBox = $(".nav-box"); $slider.stop(true, true).animate({ "left" : curP, "width" : curW }); $targetEle.mouseenter(function () { var $_parent = $(this);//.parent(), _width = $_parent.outerWidth(true), posL = $_parent.position().left; $slider.stop(true, true).animate({ "left" : posL, "width" : _width }, "fast"); }); $navBox.mouseleave(function (cur, wid) { cur = curP; wid = curW; $slider.stop(true, true).animate({ "left" : cur, "width" : wid }, "fast"); }); }; function sideSlider() { if (!$(".help-side dl").length) { return false; } var $aCur = $(".help-side dl").find(".cur a"), $targetA = $(".help-side dl dd a"), $sideSilder = $(".side-slider"), curT = $aCur.position().top+1; $sideSilder.stop(true, true).animate({ "top" : curT }); $targetA.mouseenter(function () { var posT = $(this).position().top+1; $sideSilder.stop(true, true).animate({ "top" : posT }, 240); }).parents(".help-side").mouseleave(function (_curT) { _curT = curT $sideSilder.stop(true, true).animate({ "top" : _curT }); }); }; })(jQuery);