title: CSS selector for targeting only immediate children and not other identical descendants
body: <p>I have a nested sortable list that can have items dynamically added or removed and can be nested n-levels deep. On nesting, a new ul element is injected into whatever li element is selected to be the parent. The initial state of the list is something like the following:</p>
  
  <pre><code>&lt;ul id="parent"&gt;
      &lt;li id="One"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;1&lt;/span&gt;One&lt;/a&gt;&lt;/li&gt;
      &lt;li id="Two"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;2&lt;/span&gt;Two&lt;/a&gt;&lt;/li&gt;
      &lt;li id="Three"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;3&lt;/span&gt;Three&lt;/a&gt;
          &lt;ul&gt;
              &lt;li id="A"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;1&lt;/span&gt;A&lt;/a&gt;&lt;/li&gt;
              &lt;li id="B"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;2&lt;/span&gt;B&lt;/a&gt;&lt;/li&gt;
              &lt;li id="C"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;3&lt;/span&gt;C&lt;/a&gt;&lt;/li&gt;
              &lt;li id="D"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;4&lt;/span&gt;D&lt;/a&gt;&lt;/li&gt;
              &lt;li id="E"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;5&lt;/span&gt;E&lt;/a&gt;&lt;/li&gt;
              &lt;li id="F"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;6&lt;/span&gt;F&lt;/a&gt;&lt;/li&gt;                    
          &lt;/ul&gt;
      &lt;/li&gt;   
      &lt;li id="Four"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;4&lt;/span&gt;Four&lt;/a&gt;&lt;/li&gt;
      &lt;li id="Five"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;5&lt;/span&gt;Five&lt;/a&gt;&lt;/li&gt;
      &lt;li id="Six"&gt;&lt;a href="" class="listLink"&gt;&lt;span class="position"&gt;6&lt;/span&gt;Six&lt;/a&gt;&lt;/li&gt;                    
  &lt;/ul&gt;
  </code></pre>
  
  <p>I'm using MooTools to do the sort, etc., and it works fine, but I'm having trouble resetting the position text correctly on sort. Every CSS selector I try to use also includes <em>all</em> of the children rather than just the li elements that belong in the list and not any belonging to sublists. Assume that except for id, position, and text, each li element in all lists is identical to all others. Is there a selector for getting only the immediate children? Is there another way to do this? </p>
  
  <p>I tried some child selectors like the ones mentioned:</p>
  
  <ul>
  <li><code>ul &gt; li</code> Will select <em>all</em> li elements that are a child of a ul, not just the immediate children</li>
  <li><code>#parent &gt; li</code> Does the same as above.</li>
  </ul>
  
  <p>Here is the function that I'm currently having run when an item is dropped, which doesn't handle the sorting, which works fine, just updating the position. Note that it is also MooTools syntax:</p>
  
  <pre><code>var drop = function(el){
      el.getParents('ul').reverse().each(function(item){
          var posCount = 1;
          item.getElements('li a span[class=position]').each(function(pos){
              pos.set('text', posCount);
              posCount++;
          });
      });
  }
  </code></pre>
  
  <p>Currently, changing any item order on the main level will renumber everything 1-12, even the sublists. Changing any item on a sublist will give the correct numbers for that list, but cause the parent lists to incorrectly count all child li elements in numbering.</p>
  
  <p>I feel like this is an ugly hack, but it works:</p>
  
  <pre><code>var drop = function(){
      var ulCount = 1;
      $$('ul').each(function(item){
          if(item.get('id') != 'parent') { 
              item.set('id', 'id-'+ulCount);
          }
          var elId = item.get('id');
          var posCount = 1;
          $(document).getElements('#'+elId+'&gt;li&gt;a&gt;span[class=position]').each(function(pos){
              pos.set('text', posCount);
              posCount++;
          });
          ulCount++;
      });
  }
  </code></pre>