zoukankan      html  css  js  c++  java
  • jquery: 菜单展开合并

    html:

    <div class="knowledge-left fl">
                        <div class="menu-item down">
                            <a href="javascript:;" class="sub-title">买房准备</a>
                            <ul>
                                <li>
                                    <a href="" class="actived">购房资格</a>
                                    <a href="">购房能力</a>
                                </li>
                                <li>
                                    <a href="">购房政策</a>
                                    <a href="">交易流程</a>
                                </li>
                            </ul>
                        </div>
                        <div class="menu-item right">
                            <a href="javascript:;" class="sub-title">看房选房</a>
                            <ul>
                                <li>
                                    <a href="">选新房技巧</a>
                                    <a href="">选二手房技巧</a>
                                </li>
                                <li>
                                    <a href="">选教育地产技巧</a>
                                    <a href="">建筑类型</a>
                                </li>
                            </ul>
                        </div>
                    </div>

    js:

    <script>
        $(document).ready(function () {
            $('.menu-item .sub-title').each(function (index) {
                $(this).click(function () {
                    let _this = $(this);
                    let _parent = _this.parent();
                    let _siblings = _this.siblings('ul');
                    if (_parent.hasClass('down')) {
                        _parent.removeClass('down');
                        _parent.addClass('right');
                        _siblings.hide();
                    } else {
                        _parent.removeClass('right');
                        _parent.addClass('down');
                        _siblings.show();
                    }
                })
            })
        });
    </script>

    css:

    .knowledge-left .menu-item {
            margin-top: 20px;
        }
    
        .knowledge-left .menu-item .sub-title {
            padding-left: 16px;
            font-size: 16px;
            font-weight: bold;
            color: #333;
    
        }
    
        .knowledge-left .menu-item.down .sub-title {
            background: url("//static.fczx.com/www/assets/icons/triangle-down.png") no-repeat left center;
        }
    
        .knowledge-left .menu-item.right .sub-title {
            background: url("//static.fczx.com/www/assets/icons/triangle-right.png") no-repeat left center;
        }
    
        .knowledge-left .menu-item.right ul {
            display: none;
        }
    
        .knowledge-left .menu-item ul {
            padding-left: 16px;
            margin-top: 15px;
        }
    
        .knowledge-left .menu-item ul>li>a {
            display: inline-block;
            min-width: 140px;
            font: 14px/30px "Miscrosoft Yahei";
            color: #666;
        }
    
        .knowledge-left .menu-item ul>li>a:hover {
            color: #df2f30;
        }
    
        .knowledge-left .menu-item ul>li>a.actived {
            color: #df2f30;
            font-weight: bold;
        }
  • 相关阅读:
    Android入门程序(ListView包括一个网络状态显示)
    shell
    android.os.NetworkOnMainThreadException
    apache虚拟主机名不区分大小写的解决办法
    QT制作全屏播放器以及出现的问题
    QT使用Q_OBJECT链接不通过的一种情况
    使用PHP返回需要登录验证的HTML页面
    怎么样得到Boost的options_description的描述字符串
    QT的QHttp无信号发出,窗口程序关闭时崩溃
    apache 配置https
  • 原文地址:https://www.cnblogs.com/Nyan-Workflow-FC/p/13179660.html
Copyright © 2011-2022 走看看