jQuery官网一个关于菜单的例子
2011-07-16 00:40
330 查看
A simple show-submenu-on-hover-menu.
Markup:
Code:
Another method with less animation:
In the previous example, please use js to hide the menu (the first line) if your menu requires js. If some one doesn't have js turned on they can still get to your content. Also note you can change the show/hide to any old jQuery effect and use "slow" and "fast" to animate it.
Markup:
<ul id="menu"> <li class="menu">Sub 1 <ul> <li>test 1</li> <li>test 2</li> <li>test 3</li> <li>test 4</li> </ul> </li> <li class="menu">Sub 2 <ul> <li>test 1</li> <li>test 2</li> <li>test 3</li> <li>test 4</li> </ul> </li> </ul>
Code:
$(document).ready(function() { var toggle = function(direction, display) { return function() { var self = this; var ul = $("ul", this); if( ul.css("display") == display && !self["block" + direction] ) { self["block" + direction] = true; ul["slide" + direction]("slow", function() { self["block" + direction] = false; }); } }; } $("li.menu").hover(toggle("Down", "none"), toggle("Up", "block")); $("li.menu ul").hide(); });
Another method with less animation:
$(document).ready(function() { $("#menu li ul").hide(); $("#menu li").hover( function () { $(this).children("ul").show("slow"); },function(){ $(this).children("ul").hide("slow"); });//hover });// document ready
In the previous example, please use js to hide the menu (the first line) if your menu requires js. If some one doesn't have js turned on they can still get to your content. Also note you can change the show/hide to any old jQuery effect and use "slow" and "fast" to animate it.
相关文章推荐
- jQuery官网一个关于菜单的例子
- [Tomcat]关于Tomcat8.0的调教以及一个好用的JQuery轮盘菜单插件
- 一个关于 jquery 和 php 的 jsonp 例子(与后台PHP成功通信)
- 用jquery插件写一个小米官网左侧二级菜单
- caffe官网关于fine tuning的一个例子
- 基于jquery的类似于京东商场左菜单的一个例子
- 一个很好玩的jquery例子:小方块先逐渐显示,后向右滑动,再向左滑回,最后向上隐藏
- 《es6标准入门》chapter11中关于Proxy的一个错误例子的纠正
- 一个关于ACE Service Configurator的小例子
- 一个通过JSONP跨域调用WCF REST服务的例子(以jQuery为例)
- 关于Java Annotation的一个例子
- JQuery经典例子:可拉伸菜单
- 转:一个简单的jQuery插件ajaxfileupload实现ajax上传文件例子
- *Delphi多线程的OnTerminate属性(附加一个关于临界区线程同步的例子)
- 关于ExpandableListView用法的一个简单小例子(转)
- 关于ExpandableListView用法的一个简单小例子
- 一个关于JS作用域链的例子
- asp.net2.0(c#)关于画图的一个例子;
- 关于JbpmCenter和Mule整合实现一个审核的简单例子