Removing Elements: "Make sure you remove your <p> using the .remove() function."


Error: Make sure you remove your p using the .remove() function.

The code actually works. It removed the $p. I have no idea why this error message appeared.

$(document).ready(function() {
    var $p = $('<p>Lights will guuuuiiiiide you home. And igniiiiite your bones.</p>');     


So instead of using this code:


I used:


And it worked.

Can someone please explain to me why using the variable $p did not work?



why using the variable $p did not work?

$p is an HTML element. $('p') is an HTML selector. If you want to remove an element, you have to use a selector, and $p is for when you want to add an element :slight_smile:

Does that help any?


A post was split to a new topic: 5.Removing elements