[jQuery] Assign 'active' to nav element

[jQuery] Assign 'active' to nav element


I want my h2 element to be assigned class 'active' when selected, I have
tried numerous methods but to no avail, some guidance would be appreciated!
function initMenus() {
    $('div.menu div.gallery').hide();
    $.each($('.menu'), function(){
        $('#' + this.id + '.expandfirst div.gallery:first').show();
    });
    $('div.menu h2').click(function() {
            
            var checkElement = $(this).next();
            var parent = this.parentNode.parentNode.id;
            if($('#' + parent).hasClass('noaccordion')) {
                $(this).next().slideToggle('normal');
                return false;
            }
            if((checkElement.is('div.gallery')) && (checkElement.is(':visible'))) {
                if($('#' + parent).hasClass('collapsible')) {
                    $('#' + parent + ' div.gallery:visible').slideUp('normal');
                }
                return false;
            }
            if((checkElement.is('div.gallery')) && (!checkElement.is(':visible'))) {
                $('#' + parent + ' div.gallery:visible').slideUp('normal');
                checkElement.slideDown('normal');
                return false;
            }
        }
    );
}
$(document).ready(function() {initMenus();});
--
View this message in context: http://www.nabble.com/Assign-%27active%27-to-nav-element-tp19753801s27240p19753801.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.