Hey Wizzud. Thanks for your help - I figured it out. You're right - there was no reason to use the toggleClass function in this case. The addClass and removeClass were the way to go. It totally makes sense now - I'm just adding the "active" class to whatever existing class I need. This is very helpful! Here is my final code sample:
function toggleMode(mediaType) { // reset all tabs $(".music").removeClass("active");$(".video").removeClass("active");$(".radio").removeClass("active"); // set active if (mediaType == "1") $(".video").addClass("active"); else if (mediaType == "2") $(".music").addClass("active"); else if (mediaType == "3") $(".radio").addClass("active"); } Thanks again! By the way - cool website ;) If all you want it to do is toggle *just* the active class then do exactly that... $('.video').toggleClass('active'); However, the $('.video') selector will never find any class='video active' because you've changed them all to class='active' in the previous code. Therefore it ( $('.video') ) will only ever pick up elements that do not have 'active' class, therefore toggling is a waste of effort and you might just as well do an addClass('active')! *If* that's what you want to do? If you want to toggle both video and active (leaving *just* 'active' as the class!?) then use $('.video').removeClass('video'.addClass('active'); If you want to do something else then describe it, or give a before/ after example. BTW $(".music.active").toggleClass("music"); might just as well be $(".music.active").removeClass("music"); because the selector restricts your toggleClass() to only ever being able to remove, never add! On Nov 22, 6:43 pm, [EMAIL PROTECTED] wrote: > Hey Karl. That code just sets the element class attribute to empty: > > from this: > > <a class="video"/> > > to this > > <a class=""/> > > Thanks. > > Try $(".video").toggleClass("video active"); > > Karl Rudd > > On Nov 22, 2007 10:23 AM, <[EMAIL PROTECTED]> wrote: > > > > > The problem with the code below is that it modifies the tag to look like > > this: > > > Code: > > <a class="video video.active"/> > > > When it needs to look like this: > > > Code: > > <a class="video active"/> > > > Here is the code that I'm using: > > > Code: > > function swapMode(mediaType) { > > > $(".music.active").toggleClass("music"); > > $(".video.active").toggleClass("video"); > > $(".radio.active").toggleClass("radio"); > > > if (mediaType == "1") > > $(".video").toggleClass(".video.active"); > > else if (mediaType == "2") > > $(".music").toggleClass(".music.active"); > > else if (mediaType == "3") > > $(".radio").toggleClass(".radio.active"); > > > } > > > Thanks for your help