Search code examples
jqueryaddclassremoveclass

jquery general remove class


i have a select tag with several option value, if a value is selected, then i add a class to another div, here is my jquery:

$('#modello').change(function () {
    if ($(this).val() == "Classe B") {
        $('#header-image').removeClass('add').addClass("mod_b");
    } else if ($(this).val() == "Classe C Berlina") {
        $('#header-image').addClass("mod_cla");
    } else($(this).val() == "Classe C Coupe")('#header-image').addClass("mod_cla");
});

what i really want is to add a general remove class, without giving a name, then add a class, is it possible?


Solution

  • This will do it:

     $('#header-image').removeClass();