JavaScript Document own method: createDocumentFragment()
[this page | pdf | back links]
The createDocumentFragment() method (when
applied to the document object of the JavaScript
DOM) creates an empty DocumentFragment node.
It
has the following syntax with no parameters. It returns an empty
DocumentFragment node.
document.createDocumentFragment()
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using JavaScript:<br><br>
<span id="element"></span>
<script>
var df = document.createDocumentFragment();
var x = document.createElement("INPUT");
var att = document.createAttribute("value");
att.value = "opening value";
x.setAttributeNode(att);
df.appendChild(x);
document.getElementById("element").appendChild(df);
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedJavaScriptMethodDomCreateDocumentFragment() {
return !!document.createDocumentFragment;
} |
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)