2010-06-09 1 views

답변

2

이 같은 .next().toggle()를 사용하여 수행 할 수는 선택 일치하는 경우 다음 .nextAll('.addtitle:first'), .toggle() 사이클을 사용 사이에 뭔가있을 수 있습니다 경우

$('.ask').toggle(function() { 
    $(this).text('-').next('.addtitle').slideDown('fast'); 
}, function() { 
    $(this).text('+').next('.addtitle').slideUp('fast'); 
}); 

.next(selector)는, 다음 형제를 얻을 수 각 click 이벤트에서 제공하는 함수 사이에 있으므로 텍스트를 바꿔서 클릭 할 때마다 적절하게 슬라이드합니다.

0
$('.ask').click(function() { 
    var $this = $(this); 

    $this.find('.addtitle').slideToggle('fast', function() { 
    // Animation complete. 
    if($this.text() === '-') 
     $this.text('+'); 
    else 
     $this.text('-'); 
    }); 
}); 
+0

마크 업을보세요 ...'.addtitle'은'.ask'의 자식이 아니므로 아무런 효과가 없습니다 :) –