jquery menu inheritance
<p>I have the following simple 3 level menu structure:</p>

<pre><code>&lt;nav class="main-nav" class="list"&gt;
  &lt;ul&gt;
    &lt;li class="first lev1"&gt;&lt;a href=""&gt;Home&lt;/a&gt;&lt;/li&gt;        
    &lt;li class="lev1"&gt;&lt;a href=""&gt;Lev 1 1&lt;/a&gt;&lt;/li&gt;
    &lt;li class="lev1 hasc active"&gt;
      &lt;a href=""&gt;Lev 1 2&lt;/a&gt;
      &lt;ul&gt;
        &lt;li class="first lev2 hasc"&gt;
          &lt;a href=""&gt;Lev 2 1&lt;/a&gt;        
          &lt;ul&gt;
            &lt;li class="first lev3"&gt;&lt;a href=""&gt;&lt;/a&gt;Lev 3 1 &lt;/li&gt;
            &lt;li class="lev3"&gt;&lt;a href=""&gt;Lev 3 2&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li class="lev1 hasc active"&gt;&lt;a href=""&gt;Lev 1 3&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
&lt;/nav&gt;
</code></pre>

<p>I'm trying to make the menu work so that the second level menu slides open when it has children but is an active link when it does not and then all 3rd level links are always active links.</p>

<p>The following jquery code works for all the required functionality for the 2nd level menu (prevents default and opens the 3rd level if there are children, but if not makes the link active) the problem is that i'm not sure how to over ride the prevent default for the third level?</p>

<pre><code>$(".lev2").click(function (event) {
    event.preventDefault();
    if ($(this).hasClass('on')) {
        $(this).children('ul').slideUp();
        $(this).removeClass('on');
    } else {
        $(this).children('ul').slideDown();
        $(this).addClass('on');
    }
});
</code></pre>

<p>I've looked into starting at the root of the menu class 'main-nav' and then try to branch the code but as it is nested I'm not finding any logic that will work? any ideas most welcome.</p>
