title: jQuery: Finding partial class name
body: <p>I want to see if an <code>&lt;li&gt;</code> has a certain class, the catch is though that they all are unique but all contain a constant string of 'unqID'. I want to check to see if the <code>&lt;li&gt;</code> has a class that contains this string and if it does not, add the new class to the <code>&lt;li&gt;</code>. I know how to find out if an element has an exact class name but do not know how to find partial class names.  </p>
  
  <pre><code>&lt;li class="orange blue"&gt;
      &lt;div class="answer"&gt;Some Content&lt;/div&gt;
  &lt;/li&gt;
  &lt;input type="button" name="yellow" value="yellow" class="yellow" /&gt;
  &lt;input type="text" value="" class="result" /&gt;
  
  $("input.yellow").click(function() {
      // CREATE UNIQUE CLASS ID
      var d = new Date();
      var n = d.getTime();
      var unq = "unqID" + n;
  
      //CHECK TO SEE IF LI ALREADY HAS THE UNIQUE CLASS
      if ($("div.answer").parent().hasClass("unqID")){
          $("input.result").val("has class");
      } else {
          $("div.answer").parent().addClass(unq);
          $("input.result").val("class added");
      };
  });
  </code></pre>
  
  <p><a href="https://jsfiddle.net/CoderLevel1/c4z7yn2L/44/" rel="noreferrer">The jsFiddle</a></p>