title: get an id of child element and store in a variable using jquery?
body: <p>I'm basically trying to do exactly what the subject suggests, but I'm getting "undefined" in my alert, and I'm not entirely sure why.  I am fairly new to jquery, so, I probably have the syntax wrong, but not sure where to go from here.  I'll post both of my attempts, which both yield "undefined" in the alert... </p>
  
  <pre><code>//In my first attempt, I'm trying to get the id of the inner a tag
  &lt;ul&gt;
                  &lt;li id="l1" class="active"&gt;&lt;a href="#c1"&gt;Samp 1&lt;/a&gt;&lt;/li&gt;
                  &lt;li id="l2" class=""&gt;&lt;a href="#c2"&gt;Samp 2&lt;/a&gt;&lt;/li&gt;
                  &lt;li id="l3" class=""&gt;&lt;a href="#c3"&gt;Samp 3&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
  
  var selected = $(".active).children("a").attr("id");
      alert(selected);
  
  //In my second attempt, I'm trying to get the id of the currently selected li
      var selected = $(".active").attr("id");
      alert(selected);
  </code></pre>