Dropdown selalu slide up & down

<div class="menu">
<ul class="tree-view">
                    <li class="tree-views">
                        <a href="#pages" class="link">
                            <i class="fa fa-file"></i>
                            <span>Pages</span>
                        </a>
                        <ul class="collapsed-tree">
                            <li class="collapsed-trees">
                                <a href="">Login</a>
                            </li>
                            <li class="collapsed-trees">
                                <a href="">Register</a>
                            </li>
                        </ul>
                    </li>
 <li class="tree-views">
                        <a href="#pages" class="link">
                            <i class="fa fa-file"></i>
                            <span>Componenet</span>
                        </a>
                        <ul class="collapsed-tree">
                            <li class="collapsed-trees">
                                <a href="">Button</a>
                            </li>
                        </ul>
                    </li>
</ul>
</div<

.menu .tree-view{
    position: relative;
    margin:0px;
    padding:0px;
    border-left:30px;

}
.menu .tree-views{
    position: relative;
    margin:0px;
    padding:0px;

}
.menu .tree-view > .tree-views > .link {
    position: relative;
    color: rgba(255,255,255,.8);
    display: block;
    line-height:50px;
    text-decoration: none;
}
.menu .tree-view > .tree-views:hover > .link {
    color:white;
}
.menu .tree-view , .collapsed-tree{
    position: relative;
    margin:0px;
    padding:0px;
}

.collapsed-tree{
    display: none;
}

.menu .tree-views .collapsed-trees a{
    color:white;
    line-height:50px;
    display: block;
    text-indent: 30px;
    background: #c0392b;
}


    <script>
        $(document).ready(function () {
            $('.tree-view').on('click', (event) => {
                $(event.target).siblings('.collapsed-tree')
                    .slideDown();
            });

            $('.link').on('click', function(e) {
                $('.collapsed-tree').slideUp().e.stopPropagation()
            });

        })
    </script>

bagaimana cara mengatasi nya . saya ingin ketika dropdown pages sudah terbuka dan saya ingin klik component dan si dropdown dari pages itu terutup dan hanya terbuka yg component saja .

avatar saepudin2000
@saepudin2000

17 Kontribusi 3 Poin

Dipost 5 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban