title: jQuery: Find the text of a list item that contains a nested ul
body: <p>I have the following:</p>
  
  <pre><code>&lt;ul id="list"&gt;
  &lt;li&gt;item1
      &lt;ul&gt;
          &lt;li&gt;sub1&lt;/li&gt;
          &lt;li&gt;sub2&lt;/li&gt;
      &lt;/ul&gt;    
  &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I'd like to respond to a li click event and use the text of the li elsewhere. However, if the click is on an li that contains a nested ul, I of course get the text of all elements.</p>
  
  <pre><code>$("#list li").click(function() {
      alert($(this).text());
  });
  </code></pre>
  
  <p>returns item1sub1sub2, as expected.</p>
  
  <p>I can't figure out how to get just 'item1' if the item 1 li is clicked. I tried the following (among other things) with no luck:</p>
  
  <pre><code>$("#list li").click(function() {
      alert($(this).filter("ul").text());
  });
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>EDIT</p>
  
  <p>This is a snippet of an example - it could be multiple levels deep. I also do not want to wrap the list item text in a span or other markup.</p>