title: How to get top most div parent class
body: <p>I need to get the main <code>culpritClass</code> div class that holds everything after something is typed and enter is pressed and put it into a variable as a string. </p>
  
  <p>I can't seem to get the class.</p>
  
  <p>HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="culpritClass"&gt;
  &lt;div class="inner" style="display: block;"&gt;
  &lt;div class="inner_chat"&gt;&lt;/div&gt;
  &lt;form&gt;
  &lt;textarea class="chat_text"&gt;&lt;/textarea&gt; 
  &lt;/form&gt;     
  &lt;/div&gt;&lt;a class="culpritClass" href="#"&gt;culprit&lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I tried the following JS but I get <code>undefined</code>.</p>
  
  <pre class="lang-js prettyprint-override"><code>$('.chat_text').keypress(function(e) {
      if (e.keyCode == '13') {
  
          var ru = $(this).prev().parent().attr('class');
  
          alert(ru);
      }
  });
  </code></pre>
  
  <p>The <code>var ru</code> is the line that matters.</p>