doc: create move DOM around section
This commit is contained in:
1 parent
fa12724bfd
commit
b733777651
1 file changed
+12
-1
@@ -92,4 +92,15 @@ id("my-list").appendChild(li);
|
||||
let child = document.createElement("h2");
|
||||
child.textContent = "I am a new child!";
|
||||
id("info").replaceChild(child, qs("#info h2"));
|
||||
```
|
||||
```
|
||||
|
||||
### 在DOM周围移动节点
|
||||
当你有一个父DOM节点时,你可以使用以下函数添加或删除子DOM节点:
|
||||
|
||||
| 名称 | 描述 |
|
||||
| ----------- | ----------- |
|
||||
| parent.appendChild(node) | 将给定节点放在该节点的子节点列表的末尾 |
|
||||
| parent.insertBefore(new, old) | 将给定节点放在该节点的子节点列表中旧子节点的前面 |
|
||||
| parent.replaceChild(new, old) | 用新节点替换给定的子节点 |
|
||||
| parent.insertAdjacentElement(location, new) | 在相对于父元素的给定位置插入新元素 |
|
||||
|
||||
Reference in new issue
Block a user