Jquery 5. Removing Elements


#1


I am supposed to remove the Paragraph element using the JQuery function .remove(). I have a variable that holds the p element as such: var $p = $('p');

I call $p.remove(); to remove the p element but this doesn't work. I receive the error message: "Oops, try again. Make sure you remove your < p > using the .remove() function."

$('p').remove(); however works.

why Is calling .remove() on the var that holds the P tag not legal? Thanks.



#2

I'm guessing there is just one paragraph to remove? The above statement will remove all paragraphs in the document.

The SCT might be looking specifically at our code and expects to see the jQuery selector, not a variable.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.