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

What's wrong with my spoiler reveal?

I checked it against the final project files but can't seem to find the error. I'm on Part 3 of the Spoiler Reveal challenge (under jQuery).

The button isn't showing up, just the reveal.

//1. Hide spoiler
$(".spoiler span").hide();
//2. Add button 
$(".spoiler").append("<button>Reveal Spoiler!</button>");
//3. When button is pressed
$("button").click(function)() {
  //3.1 Show spoiler
  $( ".spoiler span").show();
  //3.2 Get rid of button
  $("this").remove();
});

2 Answers

You have a closing parenthesis ) at line 11 which is never opened. Also, I believe that line 10 should be written like this: $(this).remove();

Kennard McGill
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Kennard McGill
Full Stack JavaScript Techdegree Graduate 45,774 Points

I think Christian is referring to this line where the click method is also closing the anonymous function

$("button").click(function)() {

to

$("button").click(function() {