Search code examples
jqueryexcept

Is there something like except in jQuery?


How is this possible? Following construction does not work:

$('.multibutton').click(function(event) {

    //.. some stuff before

    $(this).next('.menu').slideDown( "slow");

    // hide all other menus except this.next.menu
    $('.menu :not(this.next)').hide();

    //.. some stuff after
});

thank you


Solution

  • $('.multibutton').click(function(event) {
    
        //.. some stuff before
    
        var elem = $(this).next('.menu').slideDown( "slow");
    
        // hide all other menus except this.next.menu
        $('.menu').not(elem).hide();
    
        //.. some stuff after
    });