http://www.imooc.com/code/1699

插入节点insertBefore()

insertBefore() 方法可在已有的子节点前插入一个新的子节点。

语法:

insertBefore(newnode,node);

参数:

newnode: 要插入的新节点。

node: 指定此节点前插入节点。

我们在来看看下面代码,在指定节点前插入节点。

插入节点insertBefore()

运行结果:

This is a new p
JavaScript
HTML

注意: otest.insertBefore(newnode,node); 也可以改为:  otest.insertBefore(newnode,otest.childNodes[0]); 

相关文章:

  • 2021-12-13
  • 2021-07-30
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
  • 2021-11-30
猜你喜欢
  • 2021-11-21
  • 2021-07-08
  • 2021-07-23
  • 2022-12-23
  • 2022-01-26
相关资源
相似解决方案