jQuery实现精美的多级下拉菜单特效

这是一款精美的多级下拉菜单美化,可以完美替代“select”来实现下拉菜单的效果。而且支持多级菜单,有加载等待效果,有层级分类展示。

代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Filament Group Lab</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="fg.menu.js"></script>
<link type="text/css" href="fg.menu.css" media="screen" rel="stylesheet" />
<link type="text/css" href="theme/ui.all.css" media="screen" rel="stylesheet" />
<!-- styles for this example page only -->
<style type="text/css">
body { font-size:62.5%; margin:0; padding:0; }
#menuLog { font-size:1.4em; margin:20px; }
.hidden { position:absolute; top:0; left:-9999px; width:1px; height:1px; overflow:hidden; }
.fg-button { clear:left; margin:0 4px 40px 450px; padding: .4em 1em; text-decoration:none !important; cursor:pointer; position: relative; text-align: center; zoom: 1; }
.fg-button .ui-icon { position: absolute; top: 50%; margin-top: -8px; left: 50%; margin-left: -8px; }
a.fg-button { float:left; }
button.fg-button { width:auto; overflow:visible; } /* removes extra button width in IE */
.fg-button-icon-left { padding-left: 2.1em; }
.fg-button-icon-right { padding-right: 2.1em; }
.fg-button-icon-left .ui-icon { right: auto; left: .2em; margin-left: 0; }
.fg-button-icon-right .ui-icon { left: auto; right: .2em; margin-left: 0; }
.fg-button-icon-solo { display:block; width:8px; text-indent: -9999px; }     /* solo icon buttons must have block properties for the text-indent to work */
.fg-button.ui-state-loading .ui-icon { background: url(spinner_bar.gif) no-repeat 0 0; }
</style>
<!-- style exceptions for IE 6 -->
<!--[if IE 6]>
    <style type="text/css">
        .fg-menu-ipod .fg-menu li { width: 95%; }
        .fg-menu-ipod .ui-widget-content { border:0; }
    </style>
    <![endif]-->
<script type="text/javascript">   
    $(function(){
        // BUTTONS
        $('.fg-button').hover(
            function(){ $(this).removeClass('ui-state-default').addClass('ui-state-focus'); },
            function(){ $(this).removeClass('ui-state-focus').addClass('ui-state-default'); }
        );
        // MENUS       
        $('#flat').menu({
            content: $('#flat').next().html(), // grab content from this page
            showSpeed: 400
        });
        $('#hierarchy').menu({
            content: $('#hierarchy').next().html(),
            crumbDefaultText: ' '
        });
        $('#hierarchybreadcrumb').menu({
            content: $('#hierarchybreadcrumb').next().html(),
            backLink: false
        });
        // or from an external source
        $.get('menuContent.html', function(data){ // grab content from another page
            $('#flyout').menu({ content: data, flyOut: true });
        });
    });
    </script>
<!-- theme switcher button -->
<script type="text/javascript" src="js/themeswitchertool"></script>
<script type="text/javascript"> $(function(){ $('<div style="position: absolute; top: 20px; right: 300px;" />').appendTo('body').themeswitcher(); }); </script>
</head>
<body>
<p id="menuLog">You chose: <span id="menuSelection"></span></p>
<a tabindex="0" href="#search-engines" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="flat"><span class="ui-icon ui-icon-triangle-1-s"></span>flat menu</a>
<div id="search-engines" class="hidden">
  <ul>
    <li><a href="#">Google</a></li>
    <li><a href="#">Yahoo</a></li>
    <li><a href="#">MSN</a></li>
    <li><a href="#">Ask</a></li>
    <li><a href="#">AOL</a></li>
  </ul>
</div>
<a tabindex="0" href="menuContent.html" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="flyout"><span class="ui-icon ui-icon-triangle-1-s"></span>flyout menu</a> <a tabindex="0" href="#news-items" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="hierarchy"><span class="ui-icon ui-icon-triangle-1-s"></span>ipod-style menu</a>
<div id="news-items" class="hidden">
  <ul>
    <li><a href="#">Breaking News</a>
      <ul>
        <li><a href="#">Entertainment</a></li>
        <li><a href="#">Politics</a></li>
        <li><a href="#">A&E</a></li>
        <li><a href="#">Sports</a>
          <ul>
            <li><a href="#">Baseball</a></li>
            <li><a href="#">Basketball</a></li>
            <li><a href="#">A really long label would wrap nicely as you can see</a></li>
            <li><a href="#">Swimming</a>
              <ul>
                <li><a href="#">High School</a></li>
                <li><a href="#">College</a></li>
                <li><a href="#">Professional</a>
                  <ul>
                    <li><a href="#">Mens Swimming</a>
                      <ul>
                        <li><a href="#">News</a></li>
                        <li><a href="#">Events</a></li>
                        <li><a href="#">Awards</a></li>
                        <li><a href="#">Schedule</a></li>
                        <li><a href="#">Team Members</a></li>
                        <li><a href="#">Fan Site</a></li>
                      </ul>
                    </li>
                    <li><a href="#">Womens Swimming</a>
                      <ul>
                        <li><a href="#">News</a></li>
                        <li><a href="#">Events</a></li>
                        <li><a href="#">Awards</a></li>
                        <li><a href="#">Schedule</a></li>
                        <li><a href="#">Team Members</a></li>
                        <li><a href="#">Fan Site</a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
                <li><a href="#">Adult Recreational</a></li>
                <li><a href="#">Youth Recreational</a></li>
                <li><a href="#">Senior Recreational</a></li>
              </ul>
            </li>
            <li><a href="#">Tennis</a></li>
            <li><a href="#">Ice Skating</a></li>
            <li><a href="#">Javascript Programming</a></li>
            <li><a href="#">Running</a></li>
            <li><a href="#">Walking</a></li>
          </ul>
        </li>
        <li><a href="#">Local</a></li>
        <li><a href="#">Health</a></li>
      </ul>
    </li>
    <li><a href="#">Entertainment</a>
      <ul>
        <li><a href="#">Celebrity news</a></li>
        <li><a href="#">Gossip</a></li>
        <li><a href="#">Movies</a></li>
        <li><a href="#">Music</a>
          <ul>
            <li><a href="#">Alternative</a></li>
            <li><a href="#">Country</a></li>
            <li><a href="#">Dance</a></li>
            <li><a href="#">Electronica</a></li>
            <li><a href="#">Metal</a></li>
            <li><a href="#">Pop</a></li>
            <li><a href="#">Rock</a>
              <ul>
                <li><a href="#">Bands</a>
                  <ul>
                    <li><a href="#">Dokken</a></li>
                  </ul>
                </li>
                <li><a href="#">Fan Clubs</a></li>
                <li><a href="#">Songs</a></li>
              </ul>
            </li>
          </ul>
        </li>
        <li><a href="#">Slide shows</a></li>
        <li><a href="#">Red carpet</a></li>
      </ul>
    </li>
    <li><a href="#">Finance</a>
      <ul>
        <li><a href="#">Personal</a>
          <ul>
            <li><a href="#">Loans</a></li>
            <li><a href="#">Savings</a></li>
            <li><a href="#">Mortgage</a></li>
            <li><a href="#">Debt</a></li>
          </ul>
        </li>
        <li><a href="#">Business</a></li>
      </ul>
    </li>
    <li><a href="#">Food & Cooking</a>
      <ul>
        <li><a href="#">Breakfast</a></li>
        <li><a href="#">Lunch</a></li>
        <li><a href="#">Dinner</a></li>
        <li><a href="#">Dessert</a>
          <ul>
            <li><a href="#">Dump Cake</a></li>
            <li><a href="#">Doritos</a></li>
            <li><a href="#">Both please.</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#">Lifestyle</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Politics</a></li>
    <li><a href="#">Sports</a>
      <ul>
        <li><a href="#">Baseball</a></li>
        <li><a href="#">Basketball</a></li>
        <li><a href="#">Swimming</a>
          <ul>
            <li><a href="#">High School</a></li>
            <li><a href="#">College</a></li>
            <li><a href="#">Professional</a>
              <ul>
                <li><a href="#">Mens Swimming</a>
                  <ul>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Events</a></li>
                    <li><a href="#">Awards</a></li>
                    <li><a href="#">Schedule</a></li>
                    <li><a href="#">Team Members</a></li>
                    <li><a href="#">Fan Site</a></li>
                  </ul>
                </li>
                <li><a href="#">Womens Swimming</a>
                  <ul>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Events</a></li>
                    <li><a href="#">Awards</a></li>
                    <li><a href="#">Schedule</a></li>
                    <li><a href="#">Team Members</a></li>
                    <li><a href="#">Fan Site</a></li>
                  </ul>
                </li>
              </ul>
            </li>
            <li><a href="#">Adult Recreational</a></li>
            <li><a href="#">Youth Recreational</a></li>
            <li><a href="#">Senior Recreational</a></li>
          </ul>
        </li>
        <li><a href="#">Tennis</a></li>
        <li><a href="#">Ice Skating</a></li>
        <li><a href="#">Javascript Programming</a></li>
        <li><a href="#">Running</a></li>
        <li><a href="#">Walking</a></li>
      </ul>
    </li>
  </ul>
</div>
<a tabindex="0" href="#news-items-2" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="hierarchybreadcrumb"><span class="ui-icon ui-icon-triangle-1-s"></span>ipod-style menu w/ breadcrumb</a>
<div id="news-items-2" class="hidden">
  <ul>
    <li><a href="#">Breaking News</a>
      <ul>
        <li><a href="#">Entertainment</a></li>
        <li><a href="#">Politics</a></li>
        <li><a href="#">A&E</a></li>
        <li><a href="#">Sports</a>
          <ul>
            <li><a href="#">Baseball</a></li>
            <li><a href="#">Basketball</a></li>
            <li><a href="#">A really long label would wrap nicely as you can see</a></li>
            <li><a href="#">Swimming</a>
              <ul>
                <li><a href="#">High School</a></li>
                <li><a href="#">College</a></li>
                <li><a href="#">Professional</a>
                  <ul>
                    <li><a href="#">Mens Swimming</a>
                      <ul>
                        <li><a href="#">News</a></li>
                        <li><a href="#">Events</a></li>
                        <li><a href="#">Awards</a></li>
                        <li><a href="#">Schedule</a></li>
                        <li><a href="#">Team Members</a></li>
                        <li><a href="#">Fan Site</a></li>
                      </ul>
                    </li>
                    <li><a href="#">Womens Swimming</a>
                      <ul>
                        <li><a href="#">News</a></li>
                        <li><a href="#">Events</a></li>
                        <li><a href="#">Awards</a></li>
                        <li><a href="#">Schedule</a></li>
                        <li><a href="#">Team Members</a></li>
                        <li><a href="#">Fan Site</a></li>
                      </ul>
                    </li>
                  </ul>
                </li>
                <li><a href="#">Adult Recreational</a></li>
                <li><a href="#">Youth Recreational</a></li>
                <li><a href="#">Senior Recreational</a></li>
              </ul>
            </li>
            <li><a href="#">Tennis</a></li>
            <li><a href="#">Ice Skating</a></li>
            <li><a href="#">Javascript Programming</a></li>
            <li><a href="#">Running</a></li>
            <li><a href="#">Walking</a></li>
          </ul>
        </li>
        <li><a href="#">Local</a></li>
        <li><a href="#">Health</a></li>
      </ul>
    </li>
    <li><a href="#">Entertainment</a>
      <ul>
        <li><a href="#">Celebrity news</a></li>
        <li><a href="#">Gossip</a></li>
        <li><a href="#">Movies</a></li>
        <li><a href="#">Music</a>
          <ul>
            <li><a href="#">Alternative</a></li>
            <li><a href="#">Country</a></li>
            <li><a href="#">Dance</a></li>
            <li><a href="#">Electronica</a></li>
            <li><a href="#">Metal</a></li>
            <li><a href="#">Pop</a></li>
            <li><a href="#">Rock</a>
              <ul>
                <li><a href="#">Bands</a>
                  <ul>
                    <li><a href="#">Dokken</a></li>
                  </ul>
                </li>
                <li><a href="#">Fan Clubs</a></li>
                <li><a href="#">Songs</a></li>
              </ul>
            </li>
          </ul>
        </li>
        <li><a href="#">Slide shows</a></li>
        <li><a href="#">Red carpet</a></li>
      </ul>
    </li>
    <li><a href="#">Finance</a>
      <ul>
        <li><a href="#">Personal</a>
          <ul>
            <li><a href="#">Loans</a></li>
            <li><a href="#">Savings</a></li>
            <li><a href="#">Mortgage</a></li>
            <li><a href="#">Debt</a></li>
          </ul>
        </li>
        <li><a href="#">Business</a></li>
      </ul>
    </li>
    <li><a href="#">Food & Cooking</a>
      <ul>
        <li><a href="#">Breakfast</a></li>
        <li><a href="#">Lunch</a></li>
        <li><a href="#">Dinner</a></li>
        <li><a href="#">Dessert</a>
          <ul>
            <li><a href="#">Dump Cake</a></li>
            <li><a href="#">Doritos</a></li>
            <li><a href="#">Both please.</a></li>
          </ul>
        </li>
      </ul>
    </li>
    <li><a href="#">Lifestyle</a></li>
    <li><a href="#">News</a></li>
    <li><a href="#">Politics</a></li>
    <li><a href="#">Sports</a>
      <ul>
        <li><a href="#">Baseball</a></li>
        <li><a href="#">Basketball</a></li>
        <li><a href="#">Swimming</a>
          <ul>
            <li><a href="#">High School</a></li>
            <li><a href="#">College</a></li>
            <li><a href="#">Professional</a>
              <ul>
                <li><a href="#">Mens Swimming</a>
                  <ul>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Events</a></li>
                    <li><a href="#">Awards</a></li>
                    <li><a href="#">Schedule</a></li>
                    <li><a href="#">Team Members</a></li>
                    <li><a href="#">Fan Site</a></li>
                  </ul>
                </li>
                <li><a href="#">Womens Swimming</a>
                  <ul>
                    <li><a href="#">News</a></li>
                    <li><a href="#">Events</a></li>
                    <li><a href="#">Awards</a></li>
                    <li><a href="#">Schedule</a></li>
                    <li><a href="#">Team Members</a></li>
                    <li><a href="#">Fan Site</a></li>
                  </ul>
                </li>
              </ul>
            </li>
            <li><a href="#">Adult Recreational</a></li>
            <li><a href="#">Youth Recreational</a></li>
            <li><a href="#">Senior Recreational</a></li>
          </ul>
        </li>
        <li><a href="#">Tennis</a></li>
        <li><a href="#">Ice Skating</a></li>
        <li><a href="#">Javascript Programming</a></li>
        <li><a href="#">Running</a></li>
        <li><a href="#">Walking</a></li>
      </ul>
    </li>
  </ul>
</div>
</body>
</html>

以上就是本文所述的全部内容了,希望对大家学习jQuery能够有所帮助。

(0)

相关推荐

  • jquery实现带渐变淡入淡出并向右依次展开的多级菜单效果实例

    本文实例讲述了jquery实现带渐变淡入淡出并向右依次展开的多级菜单效果.分享给大家供大家参考.具体如下: 这是一款核心基于jquery的多级导航菜单特效,横向向右依次展开菜单项,当然本菜单并不是完美的,因此没有怎么美化,另外包括子菜单的上级菜单中缺少一个菜单标记,这样用户有时候不知道哪个菜单中含有下级子菜单.不过添加这样一个标记似乎挺简单,你可以自己动手添加吧. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/jquery-right-show

  • jQuery插件cxSelect多级联动下拉菜单实例解析

    随着电商的火爆,这多级联动下拉菜单体现的更加充分,最明显的就是地址的多级联动下拉选择,所以这里就简单的分享一下 jQuery cxSelect 多级联动下拉菜单 cxSelect 是基于 jQuery 的多级联动菜单插件,适用于省市.商品分类等联动菜单. 列表数据通过 AJAX 获取(需要在服务器环境运行),也可以使用变量自定义,数据内容使用 JSON 格式. 提供国内省市县数据(数据来源:basecss/cityData Date: 2014.03.31) 个人一直都有习惯,当有新知识点需要学

  • jquery 多级下拉菜单核心代码

    jquery 复制代码 代码如下: $(document).ready(function(){ $("ul li").hover(function(){ $(this).find("ul:first").show();//鼠标滑过查找li下面的第一个ul然后显示: },function(){ $(this).find("ul:first").hide();//鼠标离开隐藏li下面d的ul: }) $("ul li ul li ul&qu

  • jquery+CSS实现的多级竖向展开树形TRee菜单效果

    本文实例讲述了jquery+CSS实现的多级竖向展开树形TRee菜单效果.分享给大家供大家参考.具体如下: 这里演示垂直的树形菜单,应用CSS和jquery技术来实现,显示在网页左侧比较合适,考虑到简洁,没有使用图片之类的作修饰.本效果兼容IE.火狐等主流浏览器. 运行效果截图如下: 在线演示地址如下: http://demo.jb51.net/js/2015/jquery-css-nlevel-vshow-tree-codes/ 具体代码如下: <!DOCTYPE html> <hea

  • jquery 实现二级/三级/多级联动菜单的思路及代码

    本文介绍使用jQuery的AJAX功能和asp.net来实现省市区的三级联动效果,其他二级.三级或多级联动也可以按照此方法完成. 文章中涉及到的数据表为City,为方便管理. 设计此表如下 ID:自增长字段 City_Name:城市名称 City_Code:城市代码 我们根据城市代码来查询省.市.区.城市代码结构大致如下: 内蒙古:150000,呼和浩特:150100,新城区:150101. 其他地区代码与此一样,省级为省级编号+0000,市级为省级编号+市级编号+00,地区为省级编号+市级编号

  • jQuery插件实现多级联动菜单效果

    开发中,有好多地方用到联动菜单,以前每次遇到联动菜单的时候都去重新写,代码重用率很低,前几天又遇到联动菜单的问题,总结了下,发现可以开发一个联动菜单的功能,以后想用的时候就方便多了.项目中每个页面都有引用jQuery,,开发个jQuery联动菜单插件,说动手就动手,下面跟大家分享分享. 我用的jQuery插件方式 (function($){ $.fn.casmenu=function(argvs){ //your code } })(jQuery); 其中jQuery传入的是jquery对象,需

  • jquery实现多级下拉菜单的实例代码

    复制代码 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>jquery实现多级下拉菜

  • 基于jquery实现多级菜单效果

    本文实例为大家分享了jquery实现多级菜单效果展示的具体代码,供大家参考,具体内容如下 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{ margin:0; padding:0; font-size:14px; } ul,li{ list

  • jQuery多级手风琴菜单实例讲解

    手风琴菜单一般用于下拉导航,由于外观非常简洁,使用起来跟手风琴一样可以拉伸和收缩而得名,项目中适当应用手风琴效果会给用户带来非常好的体验.本文借助jQuery插件轻松打造一个非常不错的手风琴效果的菜单. HTML 首先在head间引用jQuery和插件. <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascri

  • jQuery实现多级下拉菜单jDropMenu的方法

    本文实例讲述了jQuery实现多级下拉菜单jDropMenu的方法.分享给大家供大家参考.具体如下: 这里介绍的jQuery多级下拉菜单导航-多级下拉菜单,英文名叫 DropDown Menu.通过 each() 遍历添加相应的处理事件 mouseover,mouseout 和 tab 操作的支持.这个效果是我们平时最常见的一个效果之一,也是一个十分实用的一个 JavaScript 特效.例如我的 BlueNight 主题的主导航就使用了多级下拉菜单的这个效果. 运行效果截图如下: 在线演示地址

随机推荐