JavaScript to jQuery syntax Building custom CSS horizontal menu
<p>This is a horizontal menu using traditional JavaScript.</p>

<pre><code>function createcssmenu()
{
    var ultags = document.getElementById("navmenu").getElementsByTagName("ul");
    for (var t = 0; t &lt; ultags.length; t++)
    {
        ultags[t].style.top = ultags[t].parentNode.offsetHeight -1 + "px";
        ultags[t].parentNode.onmouseover = function()
        {
            this.style.zIndex = 100;
            this.getElementsByTagName("ul")[0].style.visibility = "visible";
            this.getElementsByTagName("ul")[0].style.zIndex = 0;
        }
        ultags[t].parentNode.onmouseout = function()
        {
            this.style.zIndex = 0;
            this.getElementsByTagName("ul")[0].style.visibility = "hidden";
            this.getElementsByTagName("ul")[0].style.zIndex = 100;
        }
    }
}

if (window.addEventListener)
    window.addEventListener("load", createcssmenu, false);
else if (window.attachEvent)
    window.attachEvent("onload", createcssmenu);
</code></pre>

<p>I need to re-write it using jQuery syntax.</p>

<p>This is where I came to:</p>

<pre><code>$(document).ready(function ()
{
    $('#navmenu ul').css('top', $('#navmenu ul').parent().height() - 1 + "px");

    $('#navmenu ul').parent().bind('mouseover', function ()
    {
        $(this).css('z-index', 100);
        $('#navmenu ul').css({ 'visibility': 'visible', 'z-index': 0 });
    });

    $('#navmenu ul').parent().bind('mouseout', function ()
    {
        $(this).css('z-index', 0);
        $('#navmenu ul').css({ 'visibility': 'hidden', 'z-index': 100 });
    });
});
</code></pre>

<p>It doesn't work correct.</p>

<p>I still have trouble with <code>this.getElementsByTagName("ul")[0]</code> line.</p>

<p>Look at JSfiddle <a href="http://jsfiddle.net/sublay/HCajr/" rel="nofollow">http://jsfiddle.net/sublay/HCajr/</a></p>

<p>It should work a normal menu.</p>

<p>Thank you!</p>

<p>Related question <a href="http://stackoverflow.com/questions/16025815/javascript-to-jquery-syntax-still-need-help-on-converting">JavaScript to jQuery syntax Still need help on Converting</a></p>
