How to add a class active in a three level of menu where href attribute has the same pass
<p>I have three level of submenu created dynamically. I want to add class="active" where the text has the same url.</p>

<p>A space and comma will be replaced with under score.</p>

<p>For example, Glass, plast, gummi og porselen page will be</p>

<pre><code>http://www.mywebsite.com/folder/Glass_plast_gummi_og_porselen.asp
</code></pre>

<p>Each href attribute has the same path as in URL</p>

<p>HTML</p>

<pre><code>&lt;ul id="submenu"&gt;
        &lt;ul&gt;&lt;li&gt;&lt;a href="Grunnskole.asp" title="" class=""&gt;Grunnskole&lt;/a&gt;


            &lt;ul&gt;&lt;li&gt;&lt;a href="Forskerspiren.asp" title="" class=""&gt;Forskerspiren&lt;/a&gt;


            &lt;ul&gt;&lt;li&gt;&lt;a href="Sikkerhet.asp" title="" class=""&gt;Sikkerhet&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Laboratorieutstyr(1).asp" title="" class=""&gt;Laboratorieutstyr&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Glass_plast_gummi_og_porselen.asp" title="" class=""&gt;Glass, plast, gummi og porselen&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Datalogging.asp" title="" class=""&gt;Datalogging&lt;/a&gt;


            &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="Mangfold_in_naturen.asp" title="" class=""&gt;Mangfold in naturen&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Kropp_og_helse.asp" title="" class=""&gt;Kropp og helse&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Verdensrommet.asp" title="" class=""&gt;Verdensrommet&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Fenomener_og_stoffer.asp" title="" class=""&gt;Fenomener og stoffer&lt;/a&gt;


            &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="Sikkerhet_og_inventar(1).asp" title="" class=""&gt;Sikkerhet og inventar&lt;/a&gt;


            &lt;/li&gt;&lt;li&gt;&lt;a href="Laboratorieutstyr.asp" title="" class=""&gt;Laboratorieutstyr&lt;/a&gt;


            &lt;/li&gt;&lt;/ul&gt;

    &lt;/ul&gt;
</code></pre>

<p>I thank you in advance.</p>
