jQuery Get Class Examples

In jQuery, Tips and Tricks by June 20th, 2012

1901 Views

Have you wanted to get class of an element or list of all class applied to an element using jQuery? In this article, I am going to share an easy way to do just that. Actual code is just 1 line, so it’s super easy to follow along.

Examples on using jQuery to Get Class

The following example assumes that there is a div with ID “my_div” and a list of all class applied to this div should be alerted, when “Get class” button is clicked.

Example: Using jQuery to get div class

Simple, isn’t it?

Do you know of any other ways to get class  or get all class list applied to an element using jQuery? Feel free to suggest by commenting below.