Skip to main content
Question Protected by Pankaj Parkar
fixed capitalization of jQuery; removed capitalization from words in title, since it's normal not to capitalize every word in a title around here
Source Link
Mark Amery
  • 158.1k
  • 92
  • 435
  • 476

Get Class Listclass list for Elementelement with jQuery

Is there a way in JQueryjQuery 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.

Get Class List for Element with jQuery

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.

Get class list for element with jQuery

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.

edited title
Link
Ufuk Hacıoğulları
  • 38.6k
  • 14
  • 120
  • 157

Get Class List for Element with JQueryjQuery

edited tags
Link
Matt Ball
  • 360.9k
  • 102
  • 655
  • 725
Source Link
Buggabill
  • 14k
  • 4
  • 44
  • 47
Loading