<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="jquery.js"></script>
<style type="text/css">
.menu_list {
width: 150px;
}
.menu_head {
padding: 8px 10px;
cursor: pointer;
position: relative;
margin:1px;
font-weight:bold;
background: #93cdff;
}
.menu_body {
display:none;
}
.menu_body a
{
padding:8px 0px;
display:block;
color:#006699;
background-color:#EFEFEF;
padding-left:10px;
font-weight:bold;
text-decoration:none;
}
.menu_body a:hover {
color:#7fb2f4;
background-color:#dfdfdf;
text-decoration:underline;
}
</style>
<script type="text/javascript">
$(function(){
$("#firstpane p.menu_head").click(function()
{
$(this).next("div.menu_body").slideToggle(300).siblings("div.menu_body").slideUp("slow");
});
$("#firstpane p.menu_head").mouseover(function()
{
$(this).css({background:"#2286c6"});
});
$("#firstpane p.menu_head").mouseout(function()
{
$(this).css({background:"#93cdff"});
});
});s
</script>
</head>
<body>
<div id="firstpane" class="menu_list">
<p class="menu_head">菜单1</p>
<div class="menu_body">
<a href="#">子菜单1</a>
<a href="#">子菜单2</a>
<a href="#">子菜单3</a>
</div>
<p class="menu_head">菜单2</p>
<div class="menu_body">
<a href="#">子菜单1</a>
<a href="#">子菜单2</a>
<a href="#">子菜单3</a>
</div>
<p class="menu_head">菜单3</p>
<div class="menu_body">
<a href="#">子菜单1</a>
<a href="#">子菜单2</a>
<a href="#">子菜单3</a>
</div>
<p class="menu_head">菜单4</p>
<div class="menu_body">
<a href="#">子菜单1</a>
<a href="#">子菜单2</a>
<a href="#">子菜单3</a>
</div>
</div>
</body>
</html>
JQuery实现折叠菜单
最新推荐文章于 2022-07-31 17:02:41 发布