dojo.empty

Project owner:Peter Higgins
Available:since V1.0

Empty the contents of a DOM element. dojo.empty deletes all children but keeps the node there.

Introduction

dojo.empty safely removes all children of the node.

Usage

1
2
3
4
<script type="text/javascript">
  // Empty node's children byId:
  dojo.empty("someId");
</script>

This function only works with DomNodes, and returns nothing.

Parameter Type Description
node String|DomNode A String ID or DomNode reference of the element to empty.

Examples

Empty a single node

Empty all nodes in a list by reference

<style type="text/css">
.green { color: white; min-width: 30px; min-height: 30px;
    border: 1px #4d4d4d solid; margin-top: 4px; margin-right: 5px;
    float: left; background-color: green; padding: 2px }
.red { color: white; min-width: 30px; min-height: 30px;
    border: 1px #4d4d4d solid; margin-top: 4px; margin-right: 5px;
    float: left; background-color: red; padding: 2px }
#panel { clear: both }
</style>
Error in the documentation? Can’t find what you are looking for? Let us know!