Remove all the children DOM elements in div

前端 未结 7 2134
萌比男神i
萌比男神i 2020-12-02 08:48

I have the following dojo codes to create a surface graphics element under a div:

....


        
7条回答
  •  一生所求
    2020-12-02 09:36

    In Dojo 1.7 or newer, use domConstruct.empty(String|DomNode):

    require(["dojo/dom-construct"], function(domConstruct){
      // Empty node's children byId:
      domConstruct.empty("someId");
    });
    

    In older Dojo, use dojo.empty(String|DomNode) (deprecated at Dojo 1.8):

    dojo.empty( id or DOM node );
    

    Each of these empty methods safely removes all children of the node.

提交回复
热议问题