Width of 3rd level of menu
<p>I have a slide down menu. In HTML I have:</p>

<pre><code>&lt;menu&gt;
    &lt;li id="vysledky"&gt;&lt;a href="#"&gt;Výsledky&lt;/a&gt;
        &lt;ul class="menu2"&gt;
            &lt;li&gt;2008
                &lt;ul class="menu3"&gt;
                    &lt;li&gt;&lt;a href="#"&gt;21.08. - MMSR SCg&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#"&gt;R SCOOechová Potôň SK&lt;/a&gt;&lt;/li&gt;
                    &lt;li&gt;&lt;a href="#"&gt;SCOOTER Brezová /Visonta/ HU&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;2010&lt;/li&gt;
            &lt;li&gt;2011&lt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/li&gt;
    &lt;li id="forum"&gt;&lt;a href="#" class="prvy"&gt;&lt;span&gt;Fórum&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/menu&gt;
</code></pre>

<p>And now i want to automaticly set the width of each 3rd level of menu (menu3) by the longest text in it. So in this example the width of this .menu3 will be the width of text "SCOOTER Brezová /Visonta/ HU".</p>

<p>I can't use css because the width of menu2 is stable and if it will be longer than menu2 its set to width of menu2 (cascade)
So i would use javascript (jquery). I have this code:</p>

<pre><code>      var i;
    var podm;

    $('menu&gt;li').each(function() {
        podm = 0;
        if($(this).children('ul').size()) {
            $(this).each(function() {

                if($(this).children('ul').size()) {
            $(this).each(function() {

                podm++;
                    i = 60;
$(this).find('li a').each(function() {
    var w = $(this).text();
    $('#js').text(w);
    w = $('#js').width();
    if(w &gt; i) {
        i = w;
    }
});
                $(this).find("ul.menu3").css("width");
                });
            }
            });
        }
    });
</code></pre>

<p>But this code works bad :-(.</p>

<p>Web: <a href="http://www.dark-project.cz/scooter/" rel="nofollow">Here</a></p>
