Delete
The delete operation is straightforward, and the Remove () method is called directly after the result set.
For example, to delete all the A elements in the following HTML script, go directly through the
$(‘a‘.remove();
You can do it.
Of course, you can also filter the selection result by passing it to the Remove parameter, and then perform the remove operation.
$(‘a‘).remove(‘.remove‘);
It is important to note that
- The remove operation does not remove the eligible elements from the result set, so you can theoretically proceed with the "delete" element
- The remove operation will delete not only the data associated with all elements of the delete element (event handlers, internally, cached data)
Replace
If you want to replace the element you are class
remove
li
<li>removed</li>
using, you can use the following two equivalent methods
$(‘li.remove‘).replaceWith(‘<li>removed</li>);
$(‘<li>removed</li>;).replaceAll(‘li.remove‘);