dojo - dojo tutorial dom-construct in Dojo - coding dojo - dojo examples
- This module can be used to :
- Create a new element.
- Delete an element from HTML document.
- Place element in HTML document.
Iinitialisation
To be able to use the dom-construct module we need to load it as fallow :
require(["dojo/dom-construct"], function(domConstruct){
// Write code here
});
create()
- This function can be used to create an element and add it in a specific position. It also allows you to set attributes and content.
Usage
var node = domConstruct.create("div", { style: { color: "red" }}, "someId", "first");
destroy()
- This function allows you to delete an element including it's children and content from the document.
Usage
domConstruct.destroy("someId");
place()
- This function can be used to place nodes in a particular position in an HTML document
Usage
domConstruct.place("someNode", "refNode", "after");
empty()
- This function can be used to delete content and all its children of a DOM element
Usage
domConstruct.empty("someId");