Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Steven Ventimiglia
Steven Ventimiglia
27,412 Points

jQuery - slideToggle a div and slideUp all others.

This is new territory for me, and I've challenged myself to figure something out. I would say it's almost there... but there's one major issue pending:

Q: Using the non-repetitive code I've established, how do I slideUp previous divs that have been toggled so they don't still appear (and go away smoothly.) Also, .siblings() only works with two divs. But when adding a third, it was not effective.

BONUS: Also give me a div inside of each window that slideToggles it closed like it would do if you closed it by clicking the div that originally toggled it open.

Contributed Solution (by Jessica Barnett):

http://jsfiddle.net/stevenventimiglia/Lx07yu68/

1 Answer

Solved it! Or I think I did...

http://jsfiddle.net/RainingRedPandas/fqwwuz0p/3/

I'm not sure if this is the best way to go about it, and It doesn't seem like the most readable code. But it works I guess.

Hope that helps!

Steven Ventimiglia
Steven Ventimiglia
27,412 Points

Awesome. Works well and great comments added to explain the changes, thanks!