0

In a function I create often DocumentFragment-object, therefore I like to remove it after the process is finish. DocumentFragment has no parent, therefore I can't use e.g.:

node.parentNode.removeChild(node);

Or e.g. using jQuery as follows:

var oDocFrag = document.createDocumentFragment();
alert($(oDocFrag).length); // shows 1
$(oDocFrag).remove(); 
alert($(oDocFrag).length); // still shows 1

Any idea how can I remove a created DocumentFragment-object? Thanks in advance.

user3815508
  • 369
  • 4
  • 20

2 Answers2

1

You can rather set it to null or empty:

 oDocFrag = null;
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

Try this one.

oDocFrag.remove();

it works for me.

refer this

Community
  • 1
  • 1
skmahawar
  • 313
  • 1
  • 13