`
long546324
  • 浏览: 204266 次
  • 性别: Icon_minigender_1
  • 来自: 云南
社区版块
存档分类
最新评论

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;
}
5
1
分享到:
评论
1 楼 naily 2012-05-29  
不错 很稳定

相关推荐

Global site tag (gtag.js) - Google Analytics