jQuery submenu like an accordion

前端 未结 1 1532
野性不改
野性不改 2021-01-26 07:52

on the webpage oshadi-yoga.ch i like to get an navigation menu with a list like this:

  • Yoga
相关标签:
1条回答
  • 2021-01-26 08:22

    I should rewrite the code al little

    <ul>
        <li class="section-title"><span>Yoga</span>
            <ul style="display: none;">
                <li><a href="/">Approach</a></li>
                <li><a href="/">Asanas</a></li>
                <li><a href="/">Yoga</a></li>
                <li><a href="/">Kirtan</a></li>
            </ul>
        </li>
    </ul>
    

    Added a span.

    jQuery:

    $('.section-title > span').on('click', function()
    {
        $(this).siblings('ul').slidetoggle();
    });
    

    I hope this helps a little (or misunderstood I the question a bit?)

    0 讨论(0)
提交回复
热议问题