zoukankan      html  css  js  c++  java
  • jquery简易的三级导航

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_732107_8hzp99uacq9.css"/>
            <style type="text/css">
                li {
                    list-style: none;
                    background-color: #1b1a1a;
                    color: #efefef;
                    line-height: 40px;
                    cursor: pointer;
                }
                li div:hover {
                    background-color: #000;
                    color: #fff;
                    box-shadow: 0 0 10px rgba(0,0,0,0.8);
                    text-shadow: 0 0 2px rgba(255,255,255,0.8);
                }
                ul {
                    padding-left: 0;
                     300px;
                    overflow: hidden;
                }
                .first i {
                    margin-right: 4px;
                    font-size: 14px;
                }
                .second div {
                    padding-left: 28px;
                }
                .third div {
                    padding-left: 46px;
                }
                .second, .third {
                    display: none;
                }
                .qf {
                    float: right;
                    padding-right: 10px;
                }
            </style>
        </head>
        <body>
            <ul class="first">
                <li>
                    <div>一级菜单 <i class="qf qf-shop-plus"></i></div>
                    <ul class="second">
                        <li>
                            <div>二级菜单</div>
                        </li>
                        <li>
                            <div>二级菜单</div>
                        </li>
                        <li>
                            <div>二级菜单 <i class="qf qf-shop-plus"></i></div>
                            <ul class="third">
                                <li><div>三级菜单 </div></li>
                                <li><div>三级菜单 </div></li>
                                <li><div>三级菜单 </div></li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>
                    <div> 一级菜单 <i class="qf qf-shop-plus"></i></div>
                    <ul class="second">
                        <li>
                            <div>二级菜单 <i class="qf qf-shop-plus"></i></div>
                            <ul class="third">
                                <li><div>三级菜单 </div></li>
                                <li><div>三级菜单 </div></li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>

            <!-- <script type="text/javascript" src="jquery.js" ></script> -->
            <script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
            <script type="text/javascript">
    //给所点击的li添加点击事件,find()找到对所有对应的子元素,添加slideToggle()的方法,组织事件冒泡
            $('.first>li').on('click',function(){
                $(this).find('.second').slideToggle();
                event.stopPropagation();
            })
            $('.second>li').on('click',function(){
                $(this).find('.third').slideToggle();
                event.stopPropagation();
            })
            $("li").on('click', function() {
                    event.stopPropagation();
                })
    //替换类名,toggleClass()的方法iconfont的类名切换,以达到加号换减号的方法
            $("li:has(ul)").on('click',function(){
                var i = $(this).children('div').children('i');
                i.toggleClass('qf-shop-plus').toggleClass('qf-shop-jianhaocu');
            })
            </script>
        </body>
    </html>
  • 相关阅读:
    用户登录设计 单点登录 记住密码等
    相同类名称但不同包启动报错
    IDEA项目搭建十一——添加拦截器、忽略URL大小写、启动事件
    IDEA项目搭建七——使用Feign简化消费者端操作
    java enum使用方法
    IDEA项目搭建十——使用slf4j和logback进行日志记录
    IDEA项目搭建九——MybatisPlus多数据库实现
    IDEA项目搭建八——使用MybatisPlus简化数据库交互
    IDEA项目搭建六——使用Eureka和Ribbon进行项目服务化
    新建Git仓库并关联远程Gitlab
  • 原文地址:https://www.cnblogs.com/yunshangwuyou/p/9265142.html
Copyright © 2011-2022 走看看