0

我正在创建一个带有子菜单的菜单,该菜单使用slideToggle 打开子菜单。默认情况下显示子菜单,请告诉我默认情况下它将如何仅显示菜单而不显示子菜单链接。

<span>Natural Rubber Reclaim</span>
  <ul>
  <div id="product_tabs">
     <li><a href='products.html'><span>Whole Tyre Reclaim</span></a></li>
     <li><a href='inner_tube_reclaim.html'><span>Inner Tube Reclaim</span></a></li>
  </div>
  </ul>


<span><a href='synthatic_reclaim_rubber.html'>Synthatic Reclaim Rubber</a></span>
<a href='products_5.html'><span>Crumb Rubber</span></a>

橡胶化合物

这是我正在使用的切换代码

<script>
        $(document).ready(function() {
            $('.accordion:eq(0)> span').click(function() {
                $(this).next().slideToggle('fast');
            });
        });
    </script>
4

1 回答 1

0

尝试

$(document).ready(function () {
    $('.accordion:eq(0) > span').click(function () {
        $(this).next().slideToggle('fast');
    });
    $('.accordion:eq(0) > span').next().hide()
});

另一种解决方案是模拟点击事件

$(document).ready(function () {
    $('.accordion:eq(0) > span').click(function () {
        $(this).next().slideToggle('fast');
    }).click();
});
于 2013-10-26T11:53:36.800 回答