title: If element has class then run function, else run another
body: <p>I have an element on my page that I want to make draggable.</p>
  
  <p>On the click event I add the class 'active' this just expands my div and the image inside it. </p>
  
  <p>So initially my div looks like...</p>
  
  <pre><code>&lt;div class="work-showcase"&gt;
  </code></pre>
  
  <p>on click it becomes...</p>
  
  <pre><code>&lt;div class="work-showcase active"&gt;
  </code></pre>
  
  <p>I want to say if the div has class active, perform X function, else perform Y.</p>
  
  <pre><code>$(body).click(function(){
  
          if($('.work-showcase').hasClass('active')){
  
              var bleft = 4900 ;
              var bright = $(window).width() - 200;
  
              $('.active &gt; ul li').draggable({
                   axis: "x", 
                   revert: false,
                   stop: function(event, ui) {
                      if(ui.position.left &lt; -bleft)
                      {   
                      $(this).animate({"left": "0px"}, 600);
                      }
                      if(ui.position.left &gt; bright)
                      {   
                      $(this).animate({"left": "0px"}, 600);
                      }
  
                  }
              });
  
  
              } else {
  
  
       var sleft = 1846 ;
       var sright = $(window).width() - 200;
  
              $('.work-showcase &gt; ul li').draggable({
                   axis: "x", 
                   revert: false,
                   stop: function(event, ui) {
                      if(ui.position.left &lt; -sleft)
                      {   
                      $(this).animate({"left": "0px"}, 600);
                      }
                      if(ui.position.left &gt; sright)
                      {   
                      $(this).animate({"left": "0px"}, 600);
                      }
  
                  }
              });
  
          }
  
      });
  </code></pre>
  
  <p>My If statement doesnt seem to work...</p>