Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Challenge Task 2 of 2 On line 13, remove the button from the DOM. $(this).remove(); not working!

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

$(".spoiler span").hide(); //2, Add a button $(".spoiler").append("<button>Reveal Spoiler!</button>"); //3, When button pressed $("button").click(function(){ //3.1, Show spoiler next to the button clicked $(this).show(); //3.2, Get rid of button $(this).remove(); });

4 Answers

Thank you, Singh,,,,,it finally worked with $(this).remove(); code!

steve try posting my code on there see if it passes

Bummer! You didn't select $(this) which is, in this context, the button you clicked on. after posting your code of $("button").remove();

Target the button its self

$("button").remove();

$("button").remove(); NOT working either after trying this statement

$(this).remove();