One thing to look at is the toggle() function. It will open if closed and close if opened. No need for the IF statement.
Also, you can animate a DIV inside a row smoothly, you don't need the whole table. To make it so that only one answer is open at any time, in the past, I have just closed them all answer.is(":visible").slideUp() and then opened the new one. Worked pretty well. I dont think you need to add classes since :visible :hidden can find them that way. Your code seems a little verbose for what you are doing. It seems like it's pretty much an accordion. http://jquery.bassistance.de/accordion/?p=1.1.1 You would just style it differently to look like a Q&A list. I hope this helps. Glen On 10/22/07, Rick Faircloth <[EMAIL PROTECTED]> wrote: > > …cause any open details div to close when another details div opens? > > $(document).ready(function() { > > $('div.calendar').find('div.details').hide().end().find('table.clickme').click(function() > { > > var answer = $(this).next(); > > if (answer.is(':visible')) { > > answer.slideUp(); > > } else { > > answer.slideDown(); > > } > > }); > > }); > > This has been working great to open a div with details when > > a table is clicked (yes, I'm using a complete table for the info because > > it animates more smoothly than a row). > > However, now I'd like for an open div to slide up when another > > table is clicked is slide down a new div. In other words, have only > > one open details div at a time. > > Perhaps I should add a class to a details div when it slides down (opens) > called "open" > > and then change the class to "closed" when another table is clicked and > then cause > > any details div's with the newly assigned "closed" class to slide up > (close)? > > If so, can this new approach be integrated into the code above or does the > > code need to be rewritten? > > Suggestions? > > Rick >