title: jQuery execute code each time element has class
body: <p>I'm trying to execute a piece of code each time a specific element has a certain class in jQuery.</p>
  
  <p>The problem I'm experiencing is that the code only executes once, then seems unactive. I'm using an if statement, but I also tried while. When I tried while the nothing really worked so that wasn't a good idea. Is there any solution? Here's the code:</p>
  
  <pre><code>if($(".slide:first").hasClass("active-slide")) {
      $(".prev").hide();
      $(".next").click (function () {
          $(".prev").show();
      });
  }
  </code></pre>