 <p>Change the JS code to only act on the first link not all sub links like below </p> <pre><code> $('.link&gt;a').on("click", function(e){ e.preventDefault(); $(this).parent('.link').siblings().children('.dropdown').fadeOut(); $(this).siblings('.dropdown').fadeToggle(); }); $(document).mouseup(function (e) { var container = $(".dropdown"); if (!container.is(e.target) // if the target of the click isn't the container... &amp;&amp; container.has(e.target).length === 0) // ... nor a descendant of the container { container.hide(); } }); </code></pre> <p>note link>a mean only first level</p> <p><a href="http://jsfiddle.net/neka5u0d/" rel="nofollow">http://jsfiddle.net/neka5u0d/</a></p>