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 jQuery Basics (2014) Creating a Spoiler Revealer Review

Carl Sergile
Carl Sergile
16,570 Points

Was this a trick question?

Hey was wondering why I got this answer wrong. I picked that the code removed the h21 element but that wasnt right. My next guess was it removed nothing...?

Which question are you referring to? There were 3 that used .remove()

Are you saying that "nothing" wasn't the correct answer or you are wondering why "nothing" is correct?

1 Answer

Steven Parker
Steven Parker
231,269 Points

:warning:SPOILER ALERT (sort of)

Given the 3 questions that ask about the remove function, only the one that references $("p").prev().remove() actually removes anything.

In the case of $("p").next().remove(), there are no elements in the given HTML following the paragraph. And in the case of $("p").prev().prev().remove(), there is only one element (not two) preceding the paragraph.