Eliminar todos los elementos infantiles jQuery
$("div").empty();
Tomas Maillo
$("div").empty();
// Remove all child nodes of the set of matched elements from the DOM
// This method does not accept any arguments.
$("div.parent").empty();
//if empty remove parent
$('#id:empty').parent().remove();
// Remove all child nodes of the set of matched elements from the DOM
// This method does not accept any arguments.
$("div.parent").empty();
$("button").click(function(){
$("div").empty();
});
empty: function() {
var elem,
i = 0;
for ( ; ( elem = this[ i ] ) != null; i++ ) {
if ( elem.nodeType === 1 ) {
// Prevent memory leaks
jQuery.cleanData( getAll( elem, false ) );
// Remove any remaining nodes
elem.textContent = "";
}
}
return this;
}