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 jQuery Basics (2014) Creating a Spoiler Revealer Perform: Part 2

Christoph Walpert
Christoph Walpert
3,752 Points

Hi my code doesn't give the desired outcome. Please review!

// Prevent spoilerphobs from seeing spoilers // Solution: Hide spoilers and reveal them through user interaction

// 1. Hide spoiler $(".spoiler span").hide(); // 2. Add a button $(".spoiler").append("<button>Reveal Spoiler!</button>"); // 3. When Button presser ยง("button").click(function(){ $(".spoiler span").show(); $(this).remove(); }); //3.1 show spoiler //3.2 get rid of button

2 Answers

You have got a typo in your code, replace ยง("button") with $("button"). Also check out the Markdown Cheatsheet on how to format your code to make it easier to read in questions.

Zachary Billingsley
Zachary Billingsley
6,187 Points

Hello!

Without knowing too much about the problem or the error you are facing I can see that you are trying select the button, but it has no identifier to reference it. So if you want to look for ALL buttons use the " : ".

https://api.jquery.com/button-selector/

Hope that helps!