December 2013
Intermediate to advanced
384 pages
9h 54m
English
$("p").remove(); $("p").remove(".menu"); $("#myList").children("li").remove();
You remove elements from the web page using the .remove([selector]) method on the jQuery object. This method modifies the DOM and removes the nodes from the tree.
There are a few different ways to use the .remove() method. Calling .remove() with no parameters removes all elements in the jQuery object’s set. For example, the following statement removes all <p> elements:
$("p").remove();
You can also pass a selector into .remove(), which limits the removal to items in the set that match the selector value. For example, the following statement removes all <p> elements with class="menu":
$("p").remove(".menu"); ...
Read now
Unlock full access