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 trialVilius Grižas
2,753 PointsAccordion. CSS or Java Script?
In the beggining of the video the he mentioned, that it's more usual to do this in Java Script. I still have no knowledge of that language, but just got curious. Dear programers, who know a lot of languages! :) If you'd get a task to do an Accordeon like this. Would you do it in CSS or Java Script? And why? :)
Vilius Grižas
2,753 PointsOh yeah, my bad. I put the wrong name. I know about the difference although I didn't worked with them. The mistake is only in the title..
Dmitro Koptev
Courses Plus Student 708 PointsStill, Javascript is one word. Jesus!
1 Answer
Iain Simmons
Treehouse Moderator 32,305 PointsIt is possible to make an accordion with either only CSS or only JavaScript, but you'll probably get the best results using a combination of the two. Generally you'll use JavaScript (JS) to handle user interaction, and change classes on the elements, and have CSS style them based on those classes.
Sergio Alen
26,726 PointsAnd the problem with doing it only using CSS3 would be cross browser support, you have less chances to deal with different browser issues using JavaScript or even better jquery
Allison Hanna
36,222 PointsAllison Hanna
36,222 PointsJust to clarify, you are asking about JavaScript, not Java. Java != JavaScript. Java is to JavaScript as Car is to Carpet. Important distinction. :)