jQuery实现侧边导航手风琴效果
来源:互联网 发布:淘宝自制女装销量好高 编辑:程序博客网 时间:2024/05/21 11:10
侧导航的手风琴效果是指,点击含子层导航的父导航时,使原本隐藏的子导航显示,再次点击,子层导航又恢复隐藏,同时,同一时间只有一个父导航的子导航能够显示
$("#sidenav > li").find('.sub-nav').hide(); var ico = '<i style="float:right;font-size:12px;" class="glyphicon glyphicon-chevron-down"></i>'; $("#sidenav > li").find('.sub-nav').prev('a').find('span').after(ico); $('#subnav .sub-nav:eq(0)').attr('id','current'); $('.sub-nav').each(function(){//.sub-nav要设一个#current $('.sub-nav ul#current').find('span').next('i').attr('class','glyphicon glyphicon-chevron-up'); $(this).parent().children('a').on('click',function(e){ e.preventDefault(); var target = $(this).parent().children('ul'); if ($(this).parent().children('a').find('span').next('i').hasClass('glyphicon glyphicon-chevron-up')) { target.slideUp(); $(this).parent().children('a').find('span').next('i').removeAttr('class','glyphicon glyphicon-chevron-up'); $(this).parent().children('a').find('span').next('i').attr('class','glyphicon glyphicon-chevron-down'); $('#sidenav ul').removeAttr("id"); } else { $('#sidenav ul').slideUp(); $('#sidenav ul').removeAttr("id"); $('#sidenav span').next('i').removeAttr('class','glyphicon glyphicon-chevron-up'); $('#sidenav span').next('i').attr('class','glyphicon glyphicon-chevron-down'); $('#sidenav span').prev('i').attr('class',"glyphicon glyphicon-list"); $(this).parent().children('a').find('span').next('i').removeAttr('class','glyphicon glyphicon-chevron-down'); $(this).parent().children('a').find('span').next('i').attr('class','glyphicon glyphicon-chevron-up'); target.slideDown(); $(this).parent("li").children('ul').attr('id','current'); } }); });
代码相对精悍
0 0
- jQuery实现侧边导航手风琴效果
- jquery实现侧边栏手风琴三级导航菜单demo
- jQuery 实现侧边浮动导航菜单效果
- 前端 jQuery 带侧边栏的手风琴效果实现 不挤压宽度 例天刀官网主页手风琴模块
- jquery实现手风琴效果
- jquery实现手风琴效果
- jQuery实现手风琴效果
- 使用jQuery实现手风琴效果
- jquery插件--实现手风琴效果
- jquery插件实现手风琴效果
- jquery插件实现手风琴效果!
- 用jquery实现手风琴效果
- jquery插件实现手风琴效果!
- 三行jquery实现手风琴效果
- Jquery 实现手风琴切换效果
- 用jquery插件实现手风琴效果
- 使用jQuery实现 模拟手风琴效果
- jQuery实现手风琴效果【详细注解】
- 第十周项目6 二叉树b中值为x的层数
- Visual Studio中 ATL CLR MFC Win32 区别
- collectionview头部悬浮
- 数值实验3:插值法
- JS递归函数和函数的callee属性
- jQuery实现侧边导航手风琴效果
- 网络吞吐量
- DSP生成hex文件、生成bin文件方法
- Color the ball
- Storm应用系列之——Spout、Bolt API
- Eclipse常用快捷键
- Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)来传递参数
- 带下划线的按钮
- iOS网络构架 与 web服务器 (三次握手)