我試圖使用JQuery切換創建滑動子菜單。我試過以下,但無濟於事:試圖在JQuery中創建滑動切換子菜單
<script> $(".menu li a").click(function(){ var ul = $(this).children("ul"); if (ul.is(":none")) { ul.slideDown(); } else { ul.slideUp(); } }); </script>
也
<script> $("ul li.menu-item a").click(function() { $(this).children("ul").toggle(); }); </script>
的HTML代碼,它適用於爲:
<div class="menu-brk-products-container">
<ul id="menu-brk-products" class="menu">
<li id="menu-item-65" class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-65"><a>Smoke Alarms – Ionisation</a>
<ul class="sub-menu">
<li id="menu-item-432" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-432"><a href="/?portfolio_cats=battery-powered-smoke-alarms">Battery Powered Alarms</a>
</li>
</ul>
</li>