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

CSS jQuery Basics (2014) Creating a Spoiler Revealer Perform: Part 3

Perform: Part 3 - spoiler span display error

Hi,

I am following along with the tutorials, and for some reason my code isn't working. I am able to hide the span and apply the button; however, the click event handler doesn't seem to be doing its job. The spoiler span is displayed on page load, and the button never appears. It's like by default the button is clicked when the page loads. Here's the code:

//1, Hide spoiler $(".spoiler span").hide(); //2, Add a button $(".spoiler").append("<button>Reveal Spoiler!</button>"); //3, When button clicked $("button").click(function() { $("spoiler span").show(); }

I noticed that I was missing the dot on the last $("spoiler span"), but that didn't seem to fix the problem

Resolved - I was missing the closing parentheses for the click function . . .

1 Answer

Resolved - I was missing the closing parentheses for the click function