Add class to every parent with jquery
<p>I am building menu with jquery, and I have set active class to selected element but I want to give active class to every parent element, can that be done</p>

<pre><code>&lt;ul class="cdrvo" id="nav"&gt;
        &lt;li class="nod1" id="1"&gt;&lt;a class=" " href="items.aspx?itemID=1"&gt;Ljevi Meni&lt;/a&gt;
            &lt;ul style="display: none; visibility: hidden;" &gt;
                &lt;li class="nod3" id="3"&gt;&lt;a class=" " href="items.aspx?itemID=3"&gt;3&lt;/a&gt;
                    &lt;ul style="display: none; visibility: hidden;" &gt;
                        &lt;li class="nod12 active" id="12"&gt;&lt;a class=" " href="items.aspx?itemID=12"&gt;12&lt;/a&gt;&lt;/li&gt;
                        &lt;li class="nod13" id="13"&gt;&lt;a class=" " href="items.aspx?itemID=13"&gt;13&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                &lt;/li&gt;
                &lt;li class="nod6" id="6"&gt;&lt;a class=" " href="items.aspx?itemID=6"&gt;6&lt;/a&gt;&lt;/li&gt;                    
            &lt;/ul&gt;
        &lt;/li&gt;
    &lt;/ul&gt;
</code></pre>
