I finally found a way to make this work, but the code dragged on a bit, and I'm sure there is a better way to do this. This is what I want, but I want to extend this to work on 10 or so divs, and the code would be funny if I used this method. I tried playing with the .each () method, but that just leads to further disappointment. If someone could point me in the right direction, I would be very obliged. Here is what I mean: http://jsfiddle.net/QbsbD/47/
$(document).ready(function() { $('#btn1').click(function() { if ('#div2:visible') { $('#div2').hide('fast'); } if ('#div3:visible') { $('#div3').hide('fast'); } $('#div1').slideToggle("slow"); }); $('#btn2').click(function() { if ('#div1:visible') { $('#div1').hide('slow'); } if ('#div3:visible') { $('#div3').hide('slow'); } $('#div2').slideToggle("slow"); }); $('#btn3').click(function() { if ('#div1:visible') { $('#div1').slideUp('slow'); } if ('#div2:visible') { $('#div2').slideUp('slow'); } $('#div3').slideToggle("slow"); }); });
source share