<!DOCTYPE html><html leng = \'en\'><head><meta charset = \'UTF-8\'/><style></style></head><body><div><i></i><b></b><span></span></div><p></p><!--<div><a></a><em></em></div>--><script>var i = document.getElementsByTagName(\'i\')[0];var b = document.getElementsByTagName(\'b\')[0];var p = document.getElementsByTagName(\'p\')[0];var span = document.getElementsByTagName(\'span\')[0];var div = document.getElementsByTagName(\'div\')[0];Element.prototype.insertAfter = function(a, b){if(a.nextElementSibling === null){a = a.nextSibling;}else{a = a.nextElementSibling;}this.insertBefore(b, a);}div.insertAfter(span, p);/*var em = document.getElementsByTagName(\'em\')[0];var a = document.getElementsByTagName(\'a\')[0];Element.prototype.insertAfter = function(a, b){//a = a.nextElementSibling;this.insertBefore(b, a);}var div = document.getElementsByTagName(\'div\')[0];div.insertAfter(a, em);*/</script></body></html>
js写封装函数insertAfter()
未经允许不得转载:爱站程序员基地 » js写封装函数insertAfter()