我正在尝试在移动设备上为下拉菜单制作切换事件。因此,当您单击该链接时,会出现下拉列表,当您再次单击它时,它会消失。由于某种原因,它不起作用。这是我的代码:
<ul class="nav-list">
<li class="mobile-homepage"><a (click)="selectPage('homepage')">{{'NAVIGATION_HOMEPAGE'|translate}}</a></li>
<li><a (click)="selectPage('solutions')" class="main-links separate">{{'NAVIGATION_SOLUTIONS'|translate}}</a>
<ul class="nav-dropdown set-width">
<li><a (click)="selectPage('solutions', 'collect')" >{{'NAVIGATION_CLICK_COLLECT'|translate}}</a></li>
<li><a (click)="selectPage('solutions', 'returns')">{{'NAVIGATION_STORE_RETURNS'|translate}}</a></li>
<li><a (click)="selectPage('solutions', 'aisle')" >{{'NAVIGATION_ENDLESS_AISLE'|translate}}</a></li>
<li><a (click)="selectPage('solutions', 'store')" >{{'NAVIGATION_STORE_FULFILMENT'|translate}}</a></li>
<li><a (click)="selectPage('solutions', 'customer')" >{{'NAVIGATION_CUSTOMER_CARE'|translate}}</a></li>
<li><a (click)="selectPage('solutions', 'partner')" >{{'NAVIGATION_PARTNER_FULFILMENT'|translate}}</a></li>
</ul>
</li>
这是我的jQuery:
if (windowWidth < 800) {
$('nav > ul > li > a:not(.only-child').click(function(e){
$(".nav-dropdown").hide();
$(this).next('.nav-dropdown').slideToggle();
e.stopPropagation();
})
}
当我点击它打开并向下滑动时发生了什么事情,但当我再次点击它时,它不会向上滑动,只是向下滑动再次打开。我做错了什么?