这怎么可能?以下构造不起作用:
$('.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
});
谢谢
答案 0 :(得分: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
});
答案 1 :(得分:0)
尝试使用jQuery.not()函数获取不包括指定项目的元素列表:
$('.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
});
有关jQuery.not()的更多信息。