How to remove or empty elements in jQuery

Bookmark and Share
July 6, 2010 Category: jQuery Tips

Removing or emptying dom elements with jQuery

// Removes the element from the dom
$('selector').remove()
 
// Empties the element
$('selector').empty();

Note that this will empty or remove every element matched by the selector, so if you have 25 divs with the class “article-content” and you do $(’div.article-content’).empty(); , It will empty the 25 divs selected.

0 comment so far

Add New Comment




Your Comment