title: Jquery If element has class which begins with x, then don't addClass
body: <p>I'm a definite newbie, so apologies for rubbish coding! 
  I've written the following Jquery for a practice project I set myself:</p>
  
  <p>When you click on the div, it has the class "in_answerbox1" added and a cloned div is created in the answerbox with the class "answerbox_letter1" added. </p>
  
  <p>Eventually there will be many divs in a grid (or cells in a table) that when you click on a particular one, it will fade out and seem to appear in the answerbox. Then when you click on the thing in the answerbox,the relevant div in the grid will reappear and the clone will be removed from the answerbox.</p>
  
  <p>However, I now want the class to be added ONLY if the thing I'm clicking on is not already in the answerbox: i.e. if either the original or the clone has a class which contains "answerbox".  </p>
  
  <p>I wrote the following knowing it wouldn't work but that it might explain what I want better.</p>
  
  <pre><code>var n = 0;
  
  $('#box').click(function(){
  
      if(!$(this).hasClass('*[class^="answerbox"]')) {
  
      $(this).addClass('in_answerbox' + (n+ 1) );
  
      $(this).clone().appendTo('#answerbox').addClass('answerbox_letter' + (n + 1));
      n = (n + 1);
  
  }
  
  
  });
  </code></pre>
  
  <p>Any suggestions?</p>