Reputation: 781
I have made a dropdown menu and it works fine, except the anchor (a href="#"
) does not work.
I think the script has something wrong, but I can't figure it out.
Can anyone can help me please?
<ul class="menu">
<li class="listMenu on">
<a class="depth1" href="#">aaa</a>
<div class="depth2Wrap">
<ul class="depth2">
<li><a href="b.html">bbb</a></li>
<li><a href="c.html">ccc</a></li>
</ul>
</div>
</li>
<li class="listMenu"><a class="depth1" href="d.html">ddd</a></li>
</ul>
$(function($) {
var li = $('.menu>.listMenu');
li.addClass('off');
$('.menu .on').find('.depth2Wrap').show();
$('.menu>.listMenu>a').click(function() {
var myArticle = $(this).parents('.listMenu:first');
if(myArticle.hasClass('off')){
li.addClass('off').removeClass('on');
li.find('.depth2Wrap').slideUp(100);
myArticle.removeClass('off').addClass('on');
myArticle.find('.depth2Wrap').slideDown(100);
li.removeClass('fir_sele');
} else {
myArticle.removeClass('on').addClass('off');
myArticle.find('.depth2Wrap').slideUp(100);
li.removeClass('fir_sele');
}
return false;
});
});
Upvotes: 0
Views: 107
Reputation: 4736
Remove the following
return false;
return false
tells the browser not to complete the default action, which is following the link.
See What's the effect of adding 'return false' to a click event listener?
Upvotes: 3