---
title: "How to get all classes of element using jquery?"  
description: "How to get all classes of element using jquery?"  
author: "Anonymous User"  
published: 2018-03-15  
updated: 2018-03-15  
canonical: https://www.mindstick.com/forum/34436/how-to-get-all-classes-of-element-using-jquery  
category: "jquery"  
tags: ["jquery", "html"]  
reading_time: 1 minute  

---

# How to get all classes of element using jquery?

Hi,

I want to get all classes of the [element using jquery](https://www.mindstick.com/forum/158691/how-can-you-change-the-css-styles-of-an-element-using-jquery).

My [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) as follows:

```
<span>
     <input title="Submit your data" name="elementName" id="elementID" onclick="return element_click(this);" type="submit" value="" class="btn btn-primary TestClass">
</span>
```

Please give me the solution to achieve this task.

## Replies

### Reply by Hemant Patel

Hi Ethan,

You can get all classes of the element by using the following line of code:

```
<script> $(document).ready(function () {
    var classes = [];
    $('.elementName').each(function () {
        classes.push($(this).attr('class'));
    });
    alert(classes);
})
</script>
```

I hope it's informative!!!


---

Original Source: https://www.mindstick.com/forum/34436/how-to-get-all-classes-of-element-using-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
