[Solved] if/else statement


I can’t try this because it’s a bit orphaned, but try the following (or at least the following idea). I was confused because your link didn’t actually include the code you posted. Try posting a jsfiddle with the code if you’re still having problems.

Your ($(‘.active’).length>0) statement doesn’t need the >0 part – all no-zero lengths will return true.

    $(function(){
        $('.thumb').hide();
        $('.subnav').click(function(){
            var menuelement = $('.thumb').eq($(this).closest("li").index());//find the matching nth element in the menu
            $(menuelement).toggleClass('active').slideToggle();
            $('.active').not(menuelement).removeClass('active').slideUp();
        });
});

solved if/else statement