-1

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

Gabriel
  • 81
  • 2
  • 9
  • 1
    The method is... drumroll please... [`.not()`](http://api.jquery.com/not/) – JJJ Oct 01 '13 at 11:45
  • Can you explain what you are attempting to do? Psuedo code isn't very helpful. – Rory McCrossan Oct 01 '13 at 11:45
  • @Juhana: see the code please before you comment.. – Gabriel Oct 01 '13 at 11:46
  • @RoryMcCrossan the menu is next to .multibutton, not in its scope, therefore I need a :not-Filter for the menu, which is next.to (this clicked) – Gabriel Oct 01 '13 at 11:48
  • @user2819288 Are you saying that `.not()` won't do what you want? Please read the documentation before you comment... – JJJ Oct 01 '13 at 11:56
  • @adeneo thank you but (I do not know why), it is not working too.. – Gabriel Oct 01 '13 at 11:56
  • @Juhana maybe my title has been chosen to be somewhat unhappy, but if you see the code, it is better understandable, but thank you for your feedback.. – Gabriel Oct 01 '13 at 11:58

2 Answers2

1
$('.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
});
adeneo
  • 312,895
  • 29
  • 395
  • 388
0

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().

Nunners
  • 3,047
  • 13
  • 17