Last active
April 23, 2018 12:19
-
-
Save ruter/ced053ad4eae35a00af6ea1c55904500 to your computer and use it in GitHub Desktop.
使用 jQuery 实现手风琴效果
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="nav"> | |
<ul> | |
<li class="nav-item"> | |
<a href="javascript:;"><i class="my-icon nav-icon icon_1"></i><span>网站配置</span><i class="my-icon nav-more"></i></a> | |
<ul style="display: none;"> | |
<li><a href="javascript:;"><span>网站设置</span></a></li> | |
<li><a href="javascript:;"><span>友情链接</span></a></li> | |
<li><a href="javascript:;"><span>分类管理</span></a></li> | |
<li><a href="javascript:;"><span>系统日志</span></a></li> | |
</ul> | |
</li> | |
<li class="nav-item"> | |
<a href="javascript:;"><i class="my-icon nav-icon icon_2"></i><span>文章管理</span><i class="my-icon nav-more"></i></a> | |
<ul style=""> | |
<li><a href="javascript:;"><span>站内新闻</span></a></li> | |
<li><a href="javascript:;"><span>站内公告</span></a></li> | |
<li><a href="javascript:;"><span>登录日志</span></a></li> | |
</ul> | |
</li> | |
<li class="nav-item"> | |
<a href="javascript:;"><i class="my-icon nav-icon icon_3"></i><span>订单管理</span><i class="my-icon nav-more"></i></a> | |
<ul style=""> | |
<li><a href="javascript:;"><span>订单列表</span></a></li> | |
<li><a href="javascript:;"><span>打个酱油</span></a></li> | |
<li><a href="javascript:;"><span>也打酱油</span></a></li> | |
</ul> | |
</li> | |
</ul> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.nav-item > a').on('click', function () { | |
var show = $(this).next().css('display') == "none"; | |
if (show) { | |
// 收起其它 | |
$('.nav-item').children('ul').slideUp(300); | |
// 展开点击的组 | |
$(this).next('ul').slideDown(300); | |
} else { | |
//收缩已展开 | |
$(this).next('ul').slideUp(300); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment