jQuery实现侧边导航栏效果

效果图:
jQuery实现侧边导航栏效果

以下是完整代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="JS代码,侧边菜单,拉出菜单,高级菜单,导航菜单,jquery菜单" />
<meta name="description" content="jQuery高级可停靠侧边栏,jquery实现的高级侧边导航菜单效果,更多侧边菜单,拉出菜单,高级菜单,导航菜单,jquery菜单请访问柯乐义JS代码频道。" />
<title>jQuery高级可停靠侧边栏_柯乐义</title>
<link type="text/css" rel="Stylesheet" href="http://keleyi.com/keleyi/phtml/jqmenu/2/keleyidock.css" />
<script type="text/javascript" src="http://keleyi.com/keleyi/pmedia/jquery/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var docked = 0;

$("#dock li ul").height($(window).height());

$("#dock .dock-keleyi-com").click(function () {
$(this).parent().parent().addClass("docked").removeClass("free");

docked += 1;
var dockH = ($(window).height()) / docked
var dockT = 0;

$("#dock li ul.docked").each(function () {
$(this).height(dockH).css("top", dockT + "px");
dockT += dockH;
});
$(this).parent().find(".undock").show();
$(this).hide();

if (docked > 0)
$("#content").css("margin-left", "250px");
else
$("#content").css("margin-left", "60px");
});

$("#dock .undock").click(function () {
$(this).parent().parent().addClass("free").removeClass("docked")
.animate({ left: "-180px" }, 200).height($(window).height()).css("top", "0px");

docked = docked - 1;
var dockH = ($(window).height()) / docked
var dockT = 0;

$("#dock li ul.docked").each(function () {
$(this).height(dockH).css("top", dockT + "px");
dockT += dockH;
});
$(this).parent().find(".dock-keleyi-com").show();
$(this).hide();

if (docked > 0)
$("#content").css("margin-left", "250px");
else
$("#content").css("margin-left", "60px");
});

$("#dock li").hover(function () {
$(this).find("ul").animate({ left: "40px" }, 200);
}, function () {
$(this).find("ul.free").animate({ left: "-180px" }, 200);
});
});
</script>
</head>
<body>
<ul >keleyi</a></p>
<p>转载请注明出处,此代码仅供学习交流,请勿用于商业用途。</p>
</div>
</body>
</html>