Is there a way in jQuery to loop through or assign to an array all of the classes that are assigned to an element?
ex.
<div class="Lorem ipsum dolor_spec sit amet">Hello World!</div>
I will be looking for a "special" class as in "dolor_spec" above. I know that I could use hasClass() but the actual class name may not necessarily be known at the time.
Best Answer
You can use
document.getElementById('divId').className.split(/\s+/);
to get you an array of class names.Then you can iterate and find the one you want.
jQuery does not really help you here...