title: jQuery - Check if element has a class from an array?
body: <p>Im trying to check if an element has a class from an array and if so what is the value of that class. At the moment I am just using:</p>
  
  <pre><code>if ($(this).hasClass('purple_grad')) {
              $thisFKeyColour = 'purple_grad';
          } else if ($(this).hasClass('red_grad')) {
              $thisFKeyColour = 'red_grad';
          } else if ($(this).hasClass('green_grad')) {
              $thisFKeyColour = 'green_grad';
          } else if ($(this).hasClass('blue_grad')) {
              $thisFKeyColour = 'blue_grad';
          } else if ($(this).hasClass('yellow_grad')) {
              $thisFKeyColour = 'yellow_grad';
          } else if ($(this).hasClass('light_yellow_grad')) {
              $thisFKeyColour = 'light_yellow_grad';
          } else if ($(this).hasClass('lighter_yellow_grad')) {
              $thisFKeyColour = 'lighter_yellow_grad';
          } else if ($(this).hasClass('grey_grad')) {
              $thisFKeyColour = 'grey_grad';
          } else if ($(this).hasClass('light_grey_grad')) {
              $thisFKeyColour = 'light_grey_grad';
          } else if ($(this).hasClass('black_grad')) {
              $thisFKeyColour = 'black_grad';
          }
  }
  alert($thisFKeyColour);
  </code></pre>
  
  <p>Is there a better way of doing this? Something like:</p>
  
  <pre><code>if (in_array(classes, element.attr('class'))) {
      $thisFKeyColour = Class_Of_Element_That_Matched_Array;
  }
  </code></pre>
  
  <p>Also, I cant just return the .attr('class') as their are multiple classes on the element.</p>
  
  <p>Cheers<br>
  Charlie</p>