appendChild:
targetElement.appendChild(newChild)
newChild作为targetElement的子节点插入最后的一子节点之后
insertBefore:
targetElement.insertBefore(newChild,existingChild)
newChild作为target的子节点插入到existingChild节点之前
existingChild为可选项参数,当为null时其效果与appendChild一样
insertAfter:
就是在targetElement后面增加new node,但是没有现成的API提供调用,但也很容易的自己可以写:
复制代码
function insertAfter(newElement, targetElement)
{
var parentElement= targetElement.parentNode;
if(parentElement.lastChild == targetElement)
{
parentElement.appendChild(newEl);
}else
{
parentElement.insertBefore(newElement,targetElement.nextSibling);
}
}