I have a dropdown menu that slides up and down when toggled to reveal it’s menu items. The problem is that when i go to click one of the menu items after the menu has slid down, it is recognized as a toggle and the menu slides up without opening the link of the menu item.
HTML
<li class="dropdown">
<a href="#">Carbohydrates, proteins & fats</a>
<ul>
<li><a href="carbohydrates.php">Carbohydrates</a></li>
<li><a href="proteins.php">Proteins</a></li>
<li><a href="fats.php">Fats</a></li>
</ul>
</li>
dropdown script:
$(document).ready(function () {
$('.dropdown').toggle(
function () {
//show its submenu
$('ul', this).slideDown(300);
},
function () {
//hide its submenu
$('ul', this).slideUp(300);
}
);
});
I’d appreciate any help with this.
Unfortunately none of the above answers were working for me. I found a solution shortly afterwards.
HTML
jquery script
That solution is working perfectly for me. I added in
e.preventDefault();to stop the page jumping up and down when i clicked on the link.