📌  相关文章
📜  一个又一个的 javscript 插入元素 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:29.648000             🧑  作者: Mango

代码示例1
//insert new Element after some reference Element
function insertAfter(newElement, referenceElement) {
    referenceElement.parentNode.insertBefore(newElement, referenceElement.nextSibling);
}

//example usage
var newElement = document.createElement("div");
    newElement.innerHTML = "my New Div Text";
var myCurrentElement= document.getElementById("myElementID");
    insertAfter(newElement, myCurrentElement);