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 trialPavel Makeev
6,207 PointsjQuery Basics. Please, Help
//1.Hide spoiler $(".spoiler span").hide(); //2.Add a button $(".spoiler").append("<button>Reveal the spoiler</button>"); //3.When the button s pressed if(
$("button").click(function(){ //3.1 Reveal spoiler $(".spoiler span").show(); //3.2 remove button
});
Concole returns: Uncaught SyntaxError: Unexpected token ;
I can't understand, what's wrong with the code.
1 Answer
Kirkland Harrell
4,444 PointsSo this is your code...
//1.Hide spoiler
$(".spoiler span").hide();
//2.Add a button
$(".spoiler").append("<button>Reveal the spoiler</button>");
//3.When the button s pressed
if($("button").click(function(){
//3.1 Reveal spoiler
$(".spoiler span").show();
//3.2 remove button
});
For the section //3 'When the button is pressed'...you have the beginning of an if statement which isn't necessary, it should simply be:
$("button").click(function(){
Pavel Makeev
6,207 PointsPavel Makeev
6,207 PointsHow stupid of me :( Thanks a lot!