jquery remove detach empty - what is the difference?
Jquery gives you 3 methods to remove element. These three methods do the same functionality ie. removing elements, but with minor changes between them.
$('#id').remove(), will cleans up id
and its child elments from DOM.
$('#id').empty(), will remove all the nested elements of id
from DOM. note:
the element #id
is still alive.
var elem=$('#id').detach(), will remove id
and its nested elements from DOM. But keeps its data and event handlers in variable if assigned.