Moogadelic wrote: > > Hi > > I tried to put together an easy accordion-like effect: > > http://www.smartforce.ch/jquery/ShowHide.html > > There is one problem: the selected-class will not be removed if all > items are closed (again). The class ".selected" should be removed if > no div is visible. How do I achieve this? "toggleClass" did not help > either. > > Thank you very much for your help! > Wizzud wrote: > > You could try... > > $(document).ready(function() { > $('div.showHide> div').hide(); > $('div.showHide> h2').click(function() { > > $(this).siblings('.selected').andSelf().toggleClass('selected').end().end() > .next('div').slideToggle('fast') > .siblings('div:visible').slideUp('fast'); > }); > }); > Wow, thank you, this works as expected! I have updated my Demo: http://www.smartforce.ch/jquery/ShowHide.html Always a pleasure to be part of the jQuery-Community! Just another little Question: Why does Firebug not always show the dynamic class ".selected", although the menu is clearly selected? Thanks anyway! -- View this message in context: http://www.nabble.com/Accordion-Like-Menu%3A-Setting-%28and-removing%29-class-on-active-item-tf4507452s15494.html#a12865259 Sent from the JQuery mailing list archive at Nabble.com.

