本文介绍了Javascript立即擦除所有节点。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在以多种选择的方式工作,我正在与几个DOM一起工作。这意味着我需要处理节点及其子节点。

当我在这里找到此链接时,我正在网上搜索从父节点删除所有节点的代码:


我使用并测试了它,但是当删除所有第一个子节点时,我认为它最终会删除父本身或第一个不允许我再次创建子节点的子节点。

所以我再次重新编写了代码,因此在我的情况下它可以更好地工作:

展开 | 选择 | Wrap | 行号

解决方案



I''m working now in a form of multiple choice and i am working with several DOM''s at once. Which means i need to work with nodes and their childs.
I was searching the web for a code that erased all nodes from a parent node when i found this link over here:
Best way to remove child nodes
I used and tested it, but when removing all first child nodes, i think it ends up by removing the parent itself or the first child node which doesn''t me allow to create child nodes again.
So i readapted the code again, so it sould work a little better in my case:

Expand|Select|Wrap|Line Numbers

解决方案




这篇关于Javascript立即擦除所有节点。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 05:28