unregister/delete all child nodes of a div tag in dojo

假装没事ソ 提交于 2019-12-11 05:37:53

问题


I have a div tag, lets say "mydivTag"

It has a child node under it with an ID of "childID"

I want to delete/unregister/whatever "childID" and then recreate a different node with the same ID, "childID"

How do I achieve removal of the first object with ID "childID" so that when I make my new object with that same ID, I don't get an error about there already being a widget registered with the ID "childID"

Thanks


回答1:


have you tried something like

dojo.query("#childID", mydivTag).orphan()

then

dojo.create("div", {id: "childID"}, mydivTag)

These are just shorthand for DOM APIs like removeChild and createElement



来源:https://stackoverflow.com/questions/4401278/unregister-delete-all-child-nodes-of-a-div-tag-in-dojo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!