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

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();