Skip to content Skip to sidebar Skip to footer

Transversing & Replacing Classes

I wish to replace a class name for a child element (ul) of parent (li.filetabs) element. What I have done seems quite right but it's obviously not as the class is not being replace

Solution 1:

I'm not sure I get this at all, but try:

$('.filetabs').on('click', function() {
    var aFileTabs = $('.filetabs'),
        curTab = $(this),
        prevCurTab = $('.cTabActive').parent();

    $('.cTabActive').removeClass('cTabActive').addClass('cPrevTabActive');
    $('ul', curTab).removeClass('cPrevTabActive').addClass ('cTabActive');
});
​

FIDDLE

Solution 2:

Answered in this separate post. Thanks Daniel.

Jquery - manipulating classes in a simple dropdown menu

Post a Comment for "Transversing & Replacing Classes"