html下拉折叠菜单,原生Js_实现简单的下拉折叠菜单(添加弹出动画效果)

  • Post author:
  • Post category:其他


用javascript实现简单的下拉折叠菜单

Gary_js实现简单的下拉折叠菜单

*{margin:0px; padding:0px;}

#div1 {width:200px; margin:0 auto; line-height:25px;}

ul {list-style:none;}

li {background:#ccc;margin-bottom:3px;}

dl {background:#eee; display:none;}

.active {background:#F90;}

//此处编写js代码,实现简单的下拉折叠菜单,默认菜单1是展开的

菜单1.1
菜单1.2
菜单1.3
菜单1.4

菜单2

菜单2.1
菜单2.2
菜单2.3
菜单2.4

菜单3

菜单3.1
菜单3.2
菜单3.3
菜单3.4

效果一

点击一级菜单时弹出二级子菜单,不需要对菜单进行 display==“none”?true:false (缺点:无法把三个一级菜单状态都设置