问题描述:

I'm trying to display the links Test 1 & Test 2 when I click on Dropdown 1. Currrently they disappear super fast. How can I fix this?

Fiddle: http://jsfiddle.net/4dm318nn/

Here is my Javascript:

 $(document).ready(function($) {

$('.inline').find('.navtoggle').click(function(){

//Expand or collapse this panel

$(this).next().slideToggle('fast');

//Hide the other panels

$(".sub-menu").not($(this).next()).slideUp('fast');

});

});

网友答案:

This dirty hack resolves my issue a little, but it's not perfect: jsfiddle.net/4dm318nn/1

<nav class="medium-8 columns primary menu">
    <ul class="inline naked">
        <li class="primary-item"><a href="http://localhost:8888/test/wordpress">Home</a></li>                       
        <li id="menu-item-74" class="primary-item menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-74"><a href="#" class="navtoggle">Dropdown 1</a>
            <ul class="sub-menu">
                <li id="menu-item-76" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-has-children menu-item-76"><a href="http://localhost:8888/test/wordpress/?page_id=45">Dropdown 2</a>
                    <ul class="sub-menu">
                        <li id="menu-item-77" class="sub-sub-menu menu-item menu-item-type-post_type menu-item-object-page menu-item-77"><a href="http://localhost:8888/test/wordpress/?page_id=47">Test 1</a></li>
                        <li id="menu-item-78" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-78"><a href="http://localhost:8888/test/wordpress/?page_id=49">Test 2</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
</nav>

  $(document).ready(function($) {
    $('.inline').find('.navtoggle').click(function(){

      //Expand or collapse this panel
      $(this).next().slideToggle('fast');

      //Hide the other panels
      $(".sub-menu").not($(this).next()).slideUp('fast');

    });
  });
相关阅读:
Top