tags:

views:

802

answers:

4

Is there any better way to rewrite this:

$('element').removeClass('class1').removeClass('class2');

Can't use removeClass(); as it would remove ALL classes, which I don't want.

Thanks

+2  A: 

err .. $('element').removeClass('class1 class2'); ?

check here

Scott Evernden
+2  A: 

http://docs.jquery.com/Attributes/removeClass

One or more CSS classes to remove from the elements, these are separated by spaces.

SeanJA
+10  A: 
$("element").removeClass("class1 class2");

From removeClass(), the class parameter:

One or more CSS classes to remove from the elements, these are separated by spaces.

cletus
Perfect! I tried with a comma, instead of space. :-)
Nimbuz
A: 

The documentation says:

class (Optional) String
One or more CSS classes to remove from the elements, these are separated by spaces.

Example:

Remove the class 'blue' and 'under' from the matched elements.

$("p:odd").removeClass("blue under");
deceze