---
title: "How to add and remove class from an element from jquery?"  
description: "How to add and remove class from an element from jquery?"  
author: "Anonymous User"  
published: 2018-04-02  
updated: 2018-04-02  
canonical: https://www.mindstick.com/forum/34452/how-to-add-and-remove-class-from-an-element-from-jquery  
category: "css-css3"  
tags: ["mvc", "css"]  
reading_time: 1 minute  

---

# How to add and remove class from an element from jquery?

Hi,

I want to [add and remove](https://www.mindstick.com/forum/160516/how-to-add-and-remove-a-column-in-datatable-in-dot-net-using-c-sharp) a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) from an element from jquery.

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

```
@Html.TextAreaFor(m => m.TextAreaName, new { @id = "textAreaId", @maxlength = 1000 })
```

Please give me some idea to achieve this task.

## Replies

### Reply by Anonymous User

Hi Franco,

You can achieve your task by following these line of code:

**For [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) class:**

```
 $("#textAreaId").addClass('TestClass');
```

**For [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) class:**

```
$("#textAreaId").removeClass('TestClass');
```

I hope it's informative!!!


---

Original Source: https://www.mindstick.com/forum/34452/how-to-add-and-remove-class-from-an-element-from-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
