title: How to check if div with class is the last element
body: <p>So here is an issue with jquery. How can I know if the div with specific class is the last element. I have following html</p>
  
  <pre><code>&lt;div class="main"&gt;
  
      &lt;div class="check"&gt;&lt;/div&gt;
      &lt;div class="check"&gt;&lt;/div&gt;
      &lt;div class="check"&gt;&lt;/div&gt;
      &lt;div class="check"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I am doing like this </p>
  
  <pre><code>jQuery(document).on('click', '.next-work', function() {
  
      var next = jQuery('.display-work').next('.check');
      jQuery('.check').removeClass('display-work');
  
      if (next) {
          next.addClass('display-work');
      } else {
          jQuery('.main .check:first').addClass('display-work');
      }
  
      jQuery('.display-work').find('.full-work-container').show();
  });
  </code></pre>
  
  <p>That means I don't want to stop adding class into div when clicking something like a slider. If the element is in the html, it should automatically add class to first.</p>