jquery下拉菜單

由於需要 用以前發過的摺疊菜單源碼改了一下 做成了下拉菜單 感覺還不錯 留着以後使用
<!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>
<title>首頁</title>
<link href="css/index.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="js/menu.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="head">
<div id="headLink">
<div class="menu">
<p class="menu_head">首頁</p>
</div>
<div class="menu">
<p class="menu_head">主菜單...</p>
<div class="menu_body">
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
</div>
</div>
<div class="menu">
<p class="menu_head">主菜單...</p>
<div class="menu_body">
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
</div>
</div>
<div class="menu">
<p class="menu_head">主菜單...</p>
<div class="menu_body">
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
</div>
</div>
<div class="menu">
<p class="menu_head">主菜單...</p>
<div class="menu_body">
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
<a href="#">子菜單...</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

$(document).ready(function(){
$(".menu_head").click(function() {

$(this).parent().find(".menu_body").slideDown('fast').show();

$(this).parent().hover(function() {
}, function(){
$(this).parent().find(".menu_body").slideUp('slow');
});

}).hover(function() {
$(this).css({color:"#F4AE34"});
}, function(){
$(this).css({color:"#000"});
});
});

*,html{
margin:0px;
padding:0px;
}
body
{
text-align:center;
font-size:12px;
font-family:宋體,Times New Roman;
}
#container{
position:relative;
margin:0px auto 0px auto;
width:1002px;
text-align:left;
}
/*頭部*/
/*頭部導航*/
#headLink
{
position:absolute;
left:305px;
top:42px;
}
#headLink .menu
{
width:80px;
text-align:center;
float:left;
}
.menu_head {
padding: 1px;
cursor: pointer;
background:url(../images/menu_head.jpg) no-repeat;
font-weight:bold;
}
.menu_body {
display:none;
}
.menu_body a
{
padding:5px 0px;
display:block;
color:#535353;
text-align:center;
background-color:#eee;
text-decoration:none;
}
.menu_body a:hover {
color:#7fb2f4;
background-color:#dfdfdf;
}
發佈了65 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章