douji9518 2019-01-07 04:38
浏览 40

如何在单击子主题菜单时关闭侧边栏菜单

So I have a sidebar menu that close on overlay, but it seems that closing the sidebar when subtopic is clicked seems smoother. I wanted to implement that code without removing the overlay function as well

Right now I have the sidebar menu that close with overlay function

<nav id="sidebar">
            <div id="dismiss">
                <i class="glyphicon glyphicon-arrow-left"></i>
            </div>

            <div class="sidebar-header">
                <h3>Tutorial OnPay</h3>
            </div>

            <ul class="list-unstyled components">
                <p>Topik 1 : Pendaftaran + Pengaktifan + Log Masuk</p>
                <li>
                    <a href="#daftar" data-toggle="collapse" aria-expanded="false">1.1 Pendaftaran OnPay</a>
                    <ul class="collapse list-unstyled" id="daftar">
                        <li><a href="#layari-laman-onpay">1.1.1 Layari Laman Web</a></li>
                        <li><a href="#pilih-subdomain">1.1.2 Pilih Subdomain</a></li>
                        <li><a href="#pilih-email">1.1.3 Pilih Emel</a></li>
                        <li><a href="#pilih-ID-dan-kata-laluan">1.1.4 Pilih ID dan Kata Laluan</a></li>
                        <li><a href="#isi-maklumat-profil-diri">1.1.5 Isi Maklumat Profil Diri</a></li>
                        <li><a href="#pengesahan-spam">1.1.6 Pengesahan Spam/Robot (reCAPTCHA)</a></li>
                        <li><a href="#klik-butang-daftar">1.1.7 Klik Butang Daftar</a></li>
                    </ul>
                </li>
</nav>

Here's the jquery part with the overlay. I wanted to implement when the subtopic is clicked the sidebar automatically close. I tried using the normal codes that i found on google but it seems to not worked.

<script type="text/javascript">
        $(document).ready(function () {
            $("#sidebar").mCustomScrollbar({
                theme: "minimal"
            });

            $('#dismiss, .overlay').on('click', function () {
                $('#sidebar').removeClass('active');
                $('.overlay').fadeOut();
            });

            $('#sidebarCollapse').on('click', function () {
                $('#sidebar').addClass('active');
                $('.overlay').fadeIn();
                $('.collapse.in').toggleClass('in');
                $('a[aria-expanded=true]').attr('aria-expanded', 'false');
            });
        });
    </script>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)