Removing DOM elements

In jQuery, you can remove the DOM elements using the remove() or empty() functions. The equivalent in JavaScript is the removeChild method.

Refer to the following code snippet to learn how to update an element through jQuery and vanilla JavaScript:

//empty the content of the element
$('#wrapper').empty();
// remove the element completely from the DOM
$('#wrapper').remove();
var elem = document.querySelector('#wrapper');
// empty the content element
while(elem.firstChild) elem.removeChild(elem.firstChild)

// remove the element completely from the DOM
elem.parentNode.removeChild(elem);