Create a documentFragment node and append a child to it (a list item). Then, change the list item's node value and insert it as the last child of the list:
The result will be:
Before the changes:
After the changes:
The createDocumentFragment() method creates a imaginary Node object, with all the properties and methods of the Node object.
The createDocumentFragment() method is usefull when you want to extract parts of your document, change, add, or delete, some of the content, and insert it back to your document.
You can also use the document's Document object to perform these changes, but to prevent destroying the document structure, it can be safer to extract only parts of the document, make the changes, and insert the part back to the document.
Note: Nodes being appended to the document fragment, from the document, will be removed from the document.
|Return Value:||A DocumentFragment object, representing the created DocumentFragment node|
|DOM Version||Core Level 1 Document Object|