jquery hasClass, can it be given the beginning of class name, to get the full class name
<p>I'm trying to do something similar to <a href="http://stackoverflow.com/questions/10333210/how-can-i-get-the-class-name-as-a-string-that-begins-with-test-using-jquery">this question</a>, but it's a bit different, so the solution there isn't working for me. </p>

<pre><code>&lt;span class="a-class another-class test-top-left"&gt;&lt;/span&gt;
</code></pre>

<p>I have an element (this code shows a <code>span</code> but it could be <code>div</code> <code>span</code> or anything). This element has a class beginning with <code>test-</code> (<code>test-top-left</code>, <code>test-top-right</code> etc.) I've triggered a click event on classes starting with <code>test-</code> and saved the clicked object as <code>var object = this;</code>. Simple stuff so far. </p>

<p>What I'm trying to do now is get the full name of that class (<code>test-top-left</code>). I know it starts with <code>test-</code> but what's the full name. <strong>The thing is that there are other classes <code>a-class</code> <code>another-class</code> and <code>test-top-left</code>.</strong> Can <code>hasClass</code> be used to get the full name of the class? I'd prefer not to use <code>find()</code> or <code>filter()</code> just because there may be additional elements within that also have <code>class="test-"</code></p>

<p><strong>Edit:</strong></p>

<p>The code I have now is, but it gives me ALL the classes. What I need is the single class beginning with <code>test-</code>. </p>

<pre><code>var object = this;
$(object).attr('class'); 
</code></pre>

<p>So now I for loop through all the classes and test each one separately, which seems like a lot of unnecessary code. I'm hoping jQuery has a clever way to get the exact class that was clicked right away.</p>
