How to add and remove class from an element from jquery?

Total Post:113

Points:791
Mvc  CSS 
 392  View(s)
Ratings:
Rate this:

Hi,

I want to add and remove a class from an element from jquery.

Here is my code:

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

Please give me some idea to achieve this task.

  1. Post:3

    Points:21
    Re: How to add and remove class from an element from jquery?

    Hi Franco,

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

    For add class:

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

    For remove class:

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

    I hope it's informative!!! 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!