5/14 question about removing paragraph


#1

Can someone explain me why in this exercise

$("p").remove(); works

and

$($paragraph).remove(); doesn't ??

And does anyone got freeze screen after trying to type $($in code ?


#2

Because you haven't declared the variable $paragraph. to declare it it should look like this $paragraph = $("p");


#3

Sorry, my bad. I did declare it in my code just didn't show it here, That's why I am asking why is not working.

It does remove it in code when you look at it but code asks directly to remove paragraph only using $("p").remove();


#4

I was having the same problem, for the code that worked I had

$(document).ready(function(){
    var $p = $('<p>Hi</p>')

$('#two').after($p)
$('p').remove();
})

But when I had this:

$(document).ready(function(){
    var $p = $('<p>Hi</p>')

$('#two').after($p)
$($p).remove();
})

it didnt let me go on. technically both codes did the job, But the lesson was asking for you to remove the p tag, so technically the first code does that while the second tag removed the variable $p. But i could be wrong.


#5

the first problem worked the other one didn't so technically the first one works better