Removing an element permanently in jQuery -


when append element , afterwards remove object still exists?

bg = $('<div class="dialog_bg"></div>'); $('#'+elm).append(bg);  bg.remove(); 

how that? isn't possible remove element permanently?

so element removed dom completely. that's fine. question how ensure element removed.

i'd use .parent() method that. because if element removed dom won't have parent anymore. may faster $("html").has(bg) because doesn't have traverse whole dom tree.

bg = $('<div class="dialog_bg"></div>'); $('#'+elm).append(bg);  bg.remove();  if(bg.parent().length == 0) {    // removed succesfully } else {    // still somewhere in dom }  // tells garbage collector free memory because there's no way access element anymore bg = null; 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -