封装函数insertAfter();功能类似insertBefore(); 提示可忽略老版本浏览器,直接在Element.prototype上编程
Element.prototype.insertAfter = function(targetNode, afterNode) {
var beforeNode = afterNode.nextElementSibling;
if (beforeNode == null) {
this.appendChild(targetNode);
} else {
this.insertBefore(targetNode, beforeNode);
}
}
var div = document.getElementsByTagName('div')[0];
var b = document.getElementsByTagName('b')[0];
var span = document.getElementsByTagName('span')[0];
var p = document.createElement('p');