javascript - Showing nav dropdown when menu item is clicked -
i twitter bootstrap, don't need features. in though drop down function i'm trying replicate.
this html:
<nav class="navigation" role="navigation"> <ul class="a"> <li><a class="" href="">page 1</a></li> <li><a class="" href="">page 2</a></li> <li> <a class="" href="">page 3</a> <ul class="drop_down"> <li><a href="#">list 1</a></li> <li><a href="#">list 2</a></li> <li class="nav_divider"></li> <li><a href="#">list 3</a></li> <li><a href="#">list 4</a></li> <li><a href="#">list 5</a></li> </ul> </li> <li><a class="" href="">page 4</a></li> <li><a class="" href="">page 5</a></li> </ul> </nav>
my javascript far (it's not much):
$('nav.navigation li a').on('click', function() { if( $('nav.navigation li').has('ul.drop_down') ) { // don't know how add class clicked item, // , not 'a' in nav. } });
$('nav.navigation li a').on('click', function(e) { if($(this).parent().has('ul.drop_down')) { $(this).siblings('ul.drop_down').addclass("classname"); e.preventdefault(); } });
calling e.preventdefault();
prevent redirecting, because don't think you'd want when want show dropdown.
Comments
Post a Comment