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
  • 349
  • 4
  • 18

2 Answers2

1

You can rather set it to null or empty:

 oDocFrag = null;
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120
0

Try this one.

oDocFrag.remove();

it works for me.

refer this

Community
  • 1
  • 1
skmahawar
  • 303
  • 1
  • 13