javascript - Open only the dropdown that was clicked -
i'm trying make dropdown. here code: fiddle
however opens each dropdown when it's been clicked, instead of 1 clicked. how can isolate it? full js:
$(function () { $('.click-nav > ul').toggleclass('no-js js'); $('.click-nav .js ul').hide(); $('.click-nav .js').click(function (e) { $('.click-nav .js ul').toggle(); $('.clicker').toggleclass('active'); e.stoppropagation(); }); $(document).click(function () { if ($('.click-nav .js ul').is(':visible')) { $('.click-nav .js ul', this).slideup(); $('.clicker').removeclass('active'); } }); });
currently whole ul
element getting clicked. add click event on .js li
nav elements li
., , use this
current relevant elements.
$('.click-nav .js li').click(function (e) { $('ul',this).toggle(); $('.clicker',this).toggleclass('active'); e.stoppropagation(); });
Comments
Post a Comment