2013-08-22 17 views

回答

0

只需滑動其他的人了第一:

$('.countystats').slideUp(); 
$('.countystats').eq(thisIs).slideDown(100); 
0

你可以試試這個棘手的方式, 你的HTML會喜歡......

<div id="1sub" class="sub">sub1</div> 
<div id="2sub" class="sub">sub2</div> 
<div id="3sub" class="sub">sub3</div> 

<div id="stream-1" class="stream" style="display:none;">Stream 1</div> 
<div id="stream-2" class="stream" style="display:none;">Stream 2</div> 
<div id="stream-3" class="stream" style="display:none;">Stream 3</div> 

現在,jQuery的

$(".sub").click(function(){ 
var subClicked = $(this).attr('id'); 
$(".stream").hide(); 
$("#stream-" + subClicked.substring(0,1)).toggle(); 
}); 
0

你可以捕捉到目前的el EMENT要操作 - 並使用.not()篩選出來

$('a.county').bind('click', function (e) { 
    var thisIs = $(this).index(); 
    var $el = $('.countystats').eq(thisIs); // element you want to toggle 
    $el.slideToggle(100); 
    $('.countystats').not($el).slideUp(100); // slide all the other ones up 
}); 

FIDDLE

0
$('a.county').on('click',function(){ 
    $('.countystats').slideUp(300); 
    $('.countystats').eq($(this).index()).slideDown(300); 
}); 

我已經更新了你的小提琴,檢查一也。 http://jsfiddle.net/Vn9RD/3/

相關問題