嗨有两个内容部分,我只想要一次打开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