javascript - Dropdown menu, anchor doesn't work -
i have made dropdown menu , works fine, except anchor (a href="#"
) not work.
i think script has wrong, can't figure out.
can can 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; }); });
remove following
return false;
return false
tells browser not complete default action, following link.
see what's effect of adding 'return false' click event listener?
Comments
Post a Comment