Directory Tree Issue


<ul id="topLevelDirectoryFiles">
  <li class="toggle" id="applications">applications
    <ul id="applications-child" class="open">
      <li class="toggle" id="applications-lib">lib</li>
      <li class="toggle" id="applications-images">images</li>
      <li class="toggle" id="applications-css">css</li>
      <li class="toggle" id="applications-views">views</li>
    </ul>
  </li>
</ul>


$('li').click(function() {
  if ($('li > ul').length) {
    alert($(this).attr('id'));
  } else {
    getDirectoryContents($(this).attr('id'));
  }
});

Okay, so the JQuery is supposed to work like this:

[LIST=1]
[]Check if an <li> is clicked
[
]If the <li> has a <ul> inside of it already
[LIST=1]
[*]Alert the <li>'s ID… (which SHOULD give me applications-lib, if you clicked on lib)
[/LIST]

[*]Otherwise get the list of directories based on the element ID
[/LIST]
For some reason when I click a 2nd tier <li> it gives me the 1st tier ID every time. Any thoughts why?