5. Can't pass yet text is removed from HTML viewer


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/web-beginner-en-v6phg/0/5?curriculum_id=50a3fad8c7a770b5fd0007a1

<In what way does your code behave incorrectly? Include ALL error messages.>

I don’t know what I am doing wrong, it seems to behave correctly in the html viewer. Thanks!



$(document).ready(function(){
    $p = $('<p>text</p>');
    $(one).after($p);
    $(two).after($p);
    ($p).remove(); // gives error 1
});

$(document).ready(function(){
    $p = $('<p>text</p>');
    $(one).after($p);
    $(two).after($p);
    ('p').remove(); // gives error 2
});

Error 1: 'Oops, try again. It looks like your < p > is still part of your HTML document. Check the Hint if you need help!'

Error 2:
‘Uncaught TypeError: “p”.remove is not a function’


#2

Two things which you forgot, the quotes ( " " ) and the # (before the one and two)

Also…[quote=“rico1, post:1, topic:35956”]
(‘p’).remove();
[/quote]

Where’s the $ at the beggining?

So, the code should look like this:

$(document).ready(function(){
    $("#one").after('<p>ADDSOMETEXTHERE</p>');
    $("#two").after($("p"));
    $('p').remove();
});

#3

Thanks, this was the code that worked.

$(document).ready(function(){
    $p = $('<p>text</p>');
    $(#one).after($p);
    $(#two).after($p);
    ('p').remove();
});