Remove all the children DOM elements in div
First of all you need to create a surface once and keep it somewhere handy. Example:
var surface = dojox.gfx.createSurface(domNode, widthInPx, heightInPx);
domNode
is usually an unadorned <div>
, which is used as a placeholder for a surface.
You can clear everything on the surface in one go (all existing shape objects will be invalidated, don't use them after that):
surface.clear();
All surface-related functions and methods can be found in the official documentation on dojox.gfx.Surface. Examples of use can be found in dojox/gfx/tests/
.
node.innerHTML = "";
Non-standard, but fast and well supported.
while (node.hasChildNodes()) {
node.removeChild(node.lastChild);
}