title: What is the best way to check if element has a class?
body: <h2>The problem</h2>
  
  <p>If the element has multiple classes then it will not match with the regular property value checking, so I'm looking for the best way to check if the object has a particular class in the element's className property.</p>
  
  <h2>Example</h2>
  
  <pre><code>// element's classname is 'hello world helloworld'
  var element = document.getElementById('element');
  
  // this obviously fails
  if(element.className == 'hello'){ ... }
  
  // this is not good if the className is just 'helloworld' because it will match
  if(element.className.indexOf('hello') != -1){ ... }  
  </code></pre>
  
  <p>So what would be the best way to do this?</p>
  
  <p><em>just pure javascript please</em></p>