私は4つのdivを持っていますが、そのうちの2つはクリック(リンク)で表示され、同じように非表示になります。他の2つのdivのリンクをクリックすると、最初の2つが再び非表示になり、その逆になります。現在、2つのリンクがクリックされた場合、4つのdivすべてが表示されます。
簡単:[リンク]>[divを表示]をクリックします。2番目のリンクをクリック>最初のdivを非表示にしながら2番目の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");
});
});