我有4个div,其中两个显示在单击(链接)上,并以相同方式隐藏。当我点击其他2个div的链接时,前两个应该再次隐藏,反之亦然。现在,如果点击2个链接,所有4个div将被显示。显示另一个div时隐藏div
简单:点击链接> show div;点击第二个链接>显示第二个div同时隐藏拳头格
的2个链接:
<a class="show_hideAbout show_hideAboutArr" href="#" >About</a>
<a class="show_hideContact show_hideContactArr" href="#" >Contact</a>
第2周的div:
<div class="slidingDivAbout">Some Content</div>
<div class="slidingDivAboutArr">
<img src="img/dropdownarrow.png" width="24" height="12" alt="">
</div>
其他2周的div:
<div class="slidingDivContact">Some Content</div>
<div class="slidingDivContactArr">
<img src="img/dropdownarrow.png" width="24" height="12" alt="">
</div>
我的脚本:
$(document).ready(function() {
$(".slidingDivAbout").hide();
$(".show_hideAbout").show();
$('.show_hideAbout').click(function() {
$(".slidingDivAbout").slideToggle(350);
});
$(".slidingDivAboutArr").hide();
$(".show_hideAboutArr").show();
$('.show_hideAboutArr').click(function() {
$(".slidingDivAboutArr").fadeToggle("fast", "linear");
});
$(".slidingDivContact").hide();
$(".show_hideContact").show();
$('.show_hideContact').click(function() {
$(".slidingDivContact").slideToggle(350);
});
$(".slidingDivContactArr").hide();
$(".show_hideContactArr").show();
$('.show_hideContactArr').click(function() {
$(".slidingDivContactArr").fadeToggle("fast", "linear");
});
});
为什么你使用多个'$(文件)。就绪()'? – thecodeparadox
你的问题是什么?并没有使用多个'$(document).ready',它们将按照定义的顺序触发,所以一个就足够了。 – JIA
好的,我得到问题部分 – JIA