多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# insertBefore 插入节点 ~~~ <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>DOM-obj</title> </head> <body> <div id="div"> <p id="pid">div的p元素</p> </div> <script> var div = document.getElementById('div'); var node = document.getElementById('pid'); var newNode = document.createElement('p'); newNode.innerHTML = '动态添加的P元素'; div.insertBefore(newNode,node); // 将创建的P元素添加在div之前 </script> </body> </html> ~~~