Toggle multiple element classes with jQuery

Why won't you use jQuery class selector?

$('.togToo').toggleClass("classC").toggleClass("classD");

You can toggle N classes all at once

$(/* selector */).toggleClass('classA classB classC');

Answer Updated

$(".main").click(function() {
    $(this).toggleClass("classA").toggleClass("classB");
    $('.togToo').toggleClass("classC").toggleClass("classD");
})

If the elements to be toggled start off with one of the two classes, you can then toggle back and forth like this:

$('#element_to_click').click( function(){
  $('.togToo').toggleClass('classC classD');
});

Tags:

Jquery