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
Amelia Franz
1,267 PointsHelp with empty anonymous function, Jquery Basics
The "Get Help" wasn't working for me, for some reason, so I'm pasting my code here in hopes that someone can help me. I was asked to add an empty anonymous function after the click handler. What's wrong with my code? (last line)
//1, Hide spoiler
$(".spoiler span").hide();
//2, Add a button
$(".spoiler").append("<button>Reveal Spoiler!</button>");
//3, When button pressed
$("button").click();
//3.1, Show spoiler
//3.2, Get rid of button
$("button").click()('function'(){});
1 Answer
Falk Schwiefert
8,706 Points//1, Hide spoiler
$(".spoiler span").hide();
//2, Add a button
$(".spoiler").append("Reveal Spoiler!");
//3, When button pressed
$("button").click(function (){});
//3.1, Show spoiler
//3.2, Get rid of button
I can't check the task right now but it sounds like you want to add the function that happens when the button is clicked. And technically the 3.1 should be inside the curly braces of the function but my phone drives me crazy and I won't mess with it any more.
Amelia Franz
1,267 PointsAmelia Franz
1,267 PointsThanks, Falk. You're right, looks like I left something out. My husband is a tech wiz who knows several programming languages, so I am going to run this by him tonight.