jQuery add CSS class

css, jquery

Solution

$('#test').removeClass();

Will remove any class that the item has you can simply add your new class after that like you are doing now

Problem

I want to remove a css class before adding a new class to an element. If I know which exact class the element has already, I can remove that by ``` $('#test').removeClass('current_class').addClass('new_class'); ``` But the problem is that `#test` does not have always same class. So I would like to remove any css class attached attached to `#test` before adding before adding a new one. How should I do that? Thanks.

Original source