2013-10-01 4 views
-1

어떻게 가능합니까? 건설에 따라 작동하지 않습니다jQuery를 제외하고 뭔가가 있습니까?

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

당신에게 감사

+1

방법은 ... 드럼 롤 제발 ... ['이 아니요()'(http://api.jquery.com/not/) – JJJ

+0

당신은 당신이하려고하는 것을 설명 할 수 있습니까? Psuedo 코드는별로 도움이되지 않습니다. –

+0

@Juhana : 당신이 코멘트하기 전에 코드를 참조하십시오 .. – Gabriel

답변

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 
}); 
+0

노력하고 불행히도 작동하지 않습니다 여기 코드가 온라인 상태입니다. http://jsfiddle.net/fhN3H/1/ – Gabriel

+1

@ user2819288 - 도대체 어떻게 된거 야? 글로벌 컨텍스트'this'는'window'이며, 다음'menu'도 없습니다. – adeneo

+0

당신이하려는 일이 이것 이니? -> http://jsfiddle.net/fhN3H/3/ – adeneo

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()에 대한 자세한 내용.

+0

시도 .. 불행히도 작동하지 않습니다 여기 코드는 지금 온라인 : http://jsfiddle.net/fhN3H/1/ – Gabriel

관련 문제