title: Get current element's classes in jQuery
body: <pre><code>​&lt;button id="test" class="example whatever"&gt;Show classes&lt;/button&gt;​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​
  
  $('button').click(function(){
    var classes = $(this).attr('class');
    alert(classes);
  });​
  </code></pre>
  
  <p>The above code returns the content of the <code>class</code> attribute. How can I get it to return the classes formatted?</p>
  
  <p>For instance, in this case, I want the variable <code>classes</code> to have a value of <code>.example.whatever</code> instead of <code>example whatever</code>.</p>
  
  <p>I've searched and the only solution that seemed to be provided is the code I demonstrated above.</p>