Maybe you can use the toggleClass() function? You could give them all a class from the beginning (e.g. closed), and in the animate function you can toggle this class. and use the class $('.closet').animate({height:'toggle',opacity:'toggle'}, 'fast');
You can also use this in combination with the callback function of the animate function (toggling the class). Hope this will help you achieve your goals. On Fri, Apr 24, 2009 at 6:02 PM, Musixz Man <mus...@hotmail.com> wrote: > > > ------------------------------ > Thanks Remon. > > But since I'm using a toggle, wouldnt I still have to know the current > state before I assigned it the "opened" class?* > * > > > > You could just add classes for open divs? > > On Fri, Apr 24, 2009 at 4:59 PM, Musixz Man <mus...@hotmail.com> wrote: > > Hi all! > > I have anywhere from 3 - 8 DIVs on a page that I open/close (animate height > toggle) via a button and want to close any (one) that are already open when > another is opened - just like an accordion. > > How do I either determine the current open state of a DIV so I know which > to close, or maybe close all of them (less efficient) before opening a new > one? > > I can't use the UI accordion because of the way the DIVs are separated and > nested deep within a bunch of other stuff. > > The code I am using to toggle them is: > > onclick="$('#slideblock_<?php echo $group['id'] > ?>').animate({height:'toggle',opacity:'toggle'}, 'fast')" > > Any help would be great. Thanks!! > > > > ------------------------------ > Windows Live™ SkyDrive™: Get 25 GB of free online storage. Check it > out.<http://windowslive.com/online/skydrive?ocid=TXT_TAGLM_WL_skydrive_042009> > > > > ------------------------------ > Rediscover Hotmail®: Get e-mail storage that grows with you. Check it > out.<http://windowslive.com/RediscoverHotmail?ocid=TXT_TAGLM_WL_HM_Rediscover_Storage2_042009> >