nested ul problem - get first parents..

nested ul problem - get first parents..

Hi, I have a problem with selecting nested ul's

This script should deactivate clicking in menu-items. The problem is, that if there more nested hidden ul's, the first child li is not clickable anymore.
I like include only the first childs of #menu into the jquery not all nested ul. Could someone give me a hint?


  1. <div id=" menu>
  2. <ul>
          <li  class="menu-item">
                  <ul>
                        <li></li>
                        <li></li>   
                   </ul> 
          </li>   
           <li class="menu-item">
                      <ul> // hidden not in menu shown!!
                        <li></li>
                        <li></li>   
                   </ul>    
          </li>
    </ul>
    </DIV>
















  1.  *  This works like so:
         *  1. Locate a nested ul.
         *  2. Select its parent item.
         *  3. Select the first a tag with in the parent item.
         *  4. Disable the onclick event for anchor tag.




  2. $('#' + menuBlockCssId + ' li ul')
                .parent()
                .each(function(){
                    $('a:first', this).click(function(){return false;});
             });
        }