Frage

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

War es hilfreich?

Lösung

$('.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
});

Andere Tipps

Try using the jQuery.not() function to get a list of the elements not including the items specified :

$('.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
});

More information on jQuery.not().

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top