Hi i’m creating a tree-like menu.
When i click on the top btn the submenu opens, and when i click again it closes.
Now, the problem is that if the submenu is open and i click on a submenu item, the submenu closes. I want it to stay open.

this is my menu:

<ul id="contentMenu" class="contentMenu">
        <li><a>Main settings</a>
                <li><a href="#">Database settings</a></li>
                <li class="last"><a href="##">Administator settings</a></li>
        <li><a>User management</a>
                <li><a href="#">New user</a></li>
                <li><a href="#">Edit users</a></li>
                <li class="last"><a href="##">Delete users</a></li>
        <li><a href="#">Admin logs</a></li>
<script type="text/javascript">createMenu("contentMenu");</script>

this is my javascript code:

createMenu = function(menuId) {
    var ulTags=document.getElementById(menuId).getElementsByTagName("ul");
    for(var i=0; i<ulTags.length; i++) {
        ulTags*.parentNode.onclick = function(e) { 
            if(this.className=="subMenu") { this.className="hideSubMenu"; } else { this.className="subMenu"; }

Any help would be appreciated!