I have 4 divs, two of them are shown on click (link), and hidden the same way. When I click the link for the other 2 divs, the first 2 should be hidden again and the other way around. Right now all 4 divs would be shown if the 2 links were clicked.
Easy: click link>show div; click second link>show second div while hiding fist div
The 2 links:
<a class="show_hideAbout show_hideAboutArr" href="#" >About</a> <a class="show_hideContact show_hideContactArr" href="#" >Contact</a> First 2 divs:
<div class="slidingDivAbout">Some Content</div> <div class="slidingDivAboutArr"> <img src="img/dropdownarrow.png" width="24" height="12" alt=""> </div> Other 2 divs:
<div class="slidingDivContact">Some Content</div> <div class="slidingDivContactArr"> <img src="img/dropdownarrow.png" width="24" height="12" alt=""> </div> And my script:
$(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"); }); });
$(document).ready()?$(document).readythey will fire in the defined order so one would be enough:)