嗨有兩個內容部分,我只想要一次打開1。基於點擊標題,它們都會崩潰並打開。我目前正在工作,他們是彼此獨立的,但我希望讓他們在顯示時隱藏另一個。我不想爲jQuery手風琴使用插件。jquery切換無線手風琴
這裏是代碼,我現在:
HTML:
<div class="topCats">
<h4><a href="#" class="openBox">Most Searched Categories</a></h4>
</div>
<div id="topCatsContainer">
content 1
</div>
<div class="allCats">
<h4><a href="#" class="closed">All Categories</a></h4>
</div>
<div id="allCatsContainer">
content 2
</div>
JS:
$('#allCatsContainer').css("display", "none");
$('.topCats h4 a').click(function() {
$('#topCatsContainer').slideToggle(500);
$(this).toggleClass("openBox");
});
$('.allCats h4 a').click(function() {
$('#allCatsContainer').slideToggle(500);
$(this).toggleClass("openBox");
});
任何幫助將不勝感激。
感謝
請貼一些相關的標記。 – yoda
更新後的帖子更完整 – estern