顶部二级菜单html,jquery实现的简单二级菜单效果代码

本文实例讲述了jquery实现的简单二级菜单效果代码。分享给大家供大家参考。具体如下:

这是一款基于jquery实现的二级菜单,研究了这么多天,才学会用jquery写一个菜单,也算是对自己的鼓励吧,自我感觉这个菜单很不错,欢迎朋友们指点江山。

运行效果截图如下:

24bd24feb26b3418780898fdbdca2f4f.png

在线演示地址如下:

具体代码如下:

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

jquery二级菜单

$(function(){

$("#container .menu1 ul li").click(function(){

var index=$("#container .menu1 ul li").index(this);

$(this).addClass("bg").siblings().removeClass();

$("#container .menu2 ul li ul").eq(index).show().parent().siblings("li").children("ul").hide();

})

})

body{ margin:0; padding:0; font-family:"宋体"; font-size:9pt; color:#FFFFFF; font-weight:bold}

#container{ width:800px; height:auto; margin:0 auto; border:1px #1025c0 solid}

#container .menu1{ width:800px; height:40px; border:none; background:url(images/menu1.gif) no-repeat}

#container .menu1 ul{ margin:0; padding:0; position:relative; padding-top:5px;}

#container .menu1 ul li{ float:left; padding-left:10px; height:35px; width:80px; line-height:35px; list-style:none; text-align:center; cursor:pointer}

#container .menu2{ width:800px; height:35px; border:none; background-color:#333333;}

#container .menu2 ul{ margin:0; padding:0}

#container .menu2 ul li{ height:35px; line-height:35px; list-style:none; float:left; cursor:pointer}

#container .menu2 ul li ul li{ float:left; padding-left:20px; height:35px; line-height:35px; list-style:none}

.bg{ background-color:#333333}

.hide{ display:none}

希望本文所述对大家的jquery程序设计有所帮助。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值