createElementNS
Summary
Creates an element from the specified namespace as a stand-alone object (unattached to the DOM).
Method of dom/Documentdom/Document
Syntax
var element = document.createElementNS(namespace, tagName);
Parameters
namespace
- Data-type
- String
The URI of the desired namespace. This is the actual URI value, not the prefix used in the mark-up.
tagName
- Data-type
- String
The name of the desired element.
Return Value
Returns an object of type DOM NodeDOM Node
The created element.
Examples
The following code example creates a circle element from the SVG namespace.
var sNamespace = "http://www.w3.org/2000/svg";
var oCircle = document.createElementNS(sNamespace, "circle");
Notes
The createElementNS method is supported only for XML namespaces.
Related specifications
- DOM Level 3 Core
- Recommendation
Attributions
Microsoft Developer Network: [Windows Internet Explorer API reference Article]