title: Uncaught TypeError: cannot read 'hasClass' property of undefined
body: <p>I need to read the class of a selected list item in an 'onClick' Listener. This element is relative to the button as I have multiple instances (quiz items on a test). I try to do so in <a href="http://jsfiddle.net/nimsson/5fW2Z/12/" rel="nofollow">http://jsfiddle.net/nimsson/5fW2Z/12/</a>.
  The error occurs in </p>
  
  <pre><code>$("ul.quiz div.quizitem div.nav span.next").click(function(e) {
      alert($(this).parent().parent().children("ul.answers li.selected")[0].hasClass("correct") ? "Correct":"Wrong");
  });
  </code></pre>
  
  <p>The html hiearchy is</p>
  
  <pre><code>&lt;ul class="quiz"&gt;
          &lt;li&gt;
              &lt;div class="quizitem"&gt;
                  &lt;div class="question"&gt;What is 2+2?&lt;/div&gt;
                  &lt;br /&gt;
                  &lt;ul class="answers"&gt;
                     &lt;li class="wrong answer"&gt;a. 5&lt;/li&gt;
                     &lt;li class="wrong answer"&gt;b. 2&lt;/li&gt;
                     &lt;li class="correct answer"&gt;c. 4&lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;br /&gt;
                  &lt;br /&gt;
                  &lt;div class="nav"&gt;&lt;span class="prev"&gt;Previous&lt;/span&gt;&lt;span class="next"&gt;Next&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt; 
          &lt;/li&gt;
          &lt;li&gt;
              &lt;div class="quizitem"&gt;
                  &lt;div class="question"&gt;What is 2+2?&lt;/div&gt;
                  &lt;br /&gt;
                  &lt;ul class="answers"&gt;
                     &lt;li class="wrong answer"&gt;a. 5&lt;/li&gt;
                     &lt;li class="wrong answer"&gt;b. 2           &lt;/li&gt;
                     &lt;li class="correct answer"&gt;c. 4&lt;/li&gt;
                  &lt;/ul&gt;
                  &lt;br /&gt;
                  &lt;br /&gt;
                  &lt;div class="nav"&gt;&lt;span class="prev"&gt;Previous&lt;/span&gt;&lt;span class="next"&gt;Next&lt;/span&gt;&lt;/div&gt;
              &lt;/div&gt; 
          &lt;/li&gt;
      &lt;/ul&gt;
  </code></pre>
  
  <p>What have I done wrong? I do believe that I have the hiearchy correct.</p>