DOMChapter07

1、createElement()方法

2、appenChild()方法

3、createTextNode()方法

4、parentElement.insertBefore(newElement,targetElement);或targetelement.parentNode.insertBefore(newElement,targetElement);

5、與insertBefore相對的insertAfter實現:

function insertAfter(newElem, targetElem) {
    var parent = targetElem.parentNode();
    if (parent.lastChild == targetElem) {
        parent.appendChild(targetElem);
    } else {
        parent.insertBefore(newElement, targetElem.nextSibling);
    }
}

發佈留言