title: How to add class to a specific siblings of element using jquery?
body: <p>I want to find if an element has class <code>lesson_read</code> then add a class <code>found</code> to <code>.course_section</code> that comes just above it. but don't add class to <code>.course_section</code> which comes below it. here is the html</p>
  
  <pre><code>&lt;table class="table"&gt;               
      &lt;tbody&gt;
          &lt;tr class="course_section "&gt;&lt;!-- this should have class "found" --&gt;
              &lt;td colspan="4"&gt;Introduction to AEM&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_lesson lesson_read"&gt;
              &lt;td class="curriculum-icon"&gt;&lt;i class="icon-play"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="#"&gt;Introduction to AEM&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt; &lt;/td&gt;
              &lt;td&gt;&lt;span class="time"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; 00:00:00&lt;/span&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_lesson lesson_read"&gt;
              &lt;td class="curriculum-icon"&gt;&lt;i class="icon-play"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="#"&gt;Installing AEM&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt; &lt;/td&gt;
              &lt;td&gt;&lt;span class="time"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; 00:00:00&lt;/span&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_lesson"&gt;
              &lt;td class="curriculum-icon"&gt;&lt;i class="icon-task"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;td&gt;AEM Installation Quiz&lt;/td&gt;
              &lt;td&gt; &lt;/td&gt;
              &lt;td&gt;&lt;span class="time"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; Unlimited&lt;/span&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_section"&gt;
              &lt;td colspan="4"&gt;AEM Environment&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_lesson"&gt;
              &lt;td class="curriculum-icon"&gt;&lt;i class="icon-text-document"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;td&gt;AEM Instances&lt;/td&gt;
              &lt;td&gt; &lt;/td&gt;
              &lt;td&gt;&lt;span class="time"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; 00:00:00&lt;/span&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr class="course_lesson"&gt;
              &lt;td class="curriculum-icon"&gt;&lt;i class="icon-play"&gt;&lt;/i&gt;&lt;/td&gt;
              &lt;td&gt;Developer Tools&lt;/td&gt;
              &lt;td&gt; &lt;/td&gt;
              &lt;td&gt;&lt;span class="time"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt; 00:00:00&lt;/span&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>I have tried this</p>
  
  <pre><code>jQuery('.course_section').each(function() {
      var c='';
      jQuery(this).siblings().each(function() {
          if(jQuery(this).hasClass('lesson_read')){
              c='found';      
          }      
      });
      if(c=='found'){
          jQuery(this).addClass(c);   
      }
  });
  </code></pre>
  
  <p>However this adds class <code>found</code> to every course section.</p>