/*dom insertion, removal, cloning domo (' Dom0 '). Clone () */! (function (w) {w.domoperation = function (id) {var _class = new Dom (); _class.init (ID); return _class; }; W.dom = function () {}; W.dom.prototype = {getid:function (id) {return document.getElementById (ID)}, Parsedom: Function (ARG) {var obje = document.createelement ("div"); obje.innerhtml = arg; return obje.childnodes; }, Init:function (ID) {this. Selector = [document.getElementById (ID)]; }, Getdom:function () {return this. Selector[0]? This. SELECTOR[0]: null; }, Append:function (HTML) {var dom = This.parsedom (html), GetDOM = This.getdom (); for (var i = 0, j = dom.length; I < J; i++) {getdom.appendchild (dom[0]); }}, Appendto:function (ID) {This.getid (id). appendchild (This.getdom ()); }, Prepend:function (HTML) {var dom = This.parsedom (html), GetDOM = This.getdom (); var first = Getdom.firstchild; for (var i = 0, j = dom.length; I < J; i++) {Getdom.insertbefore (dom[0], first); }}, Prependto:function (id) {var _indom = This.getid (ID); _indom.insertbefore (This.getdom (), _indom.firstchild); }, After:function (HTML) {var dom = This.parsedom (html), GetDOM = This.getdom (); if (Getdom.parentNode.lastChild = = GetDOM) {for (var i = 0, j = dom.length; I < J; i++) { Getdom.appendchild (Dom[0]); }} else {var nextSibling = getdom.nextsibling; for (var i = 0, j = dom.length; I < J; i++) {Getdom.parentNode.insertBefore (dom[0], nextSibling); }}}, Before:function (HTML) { var dom = this.parsedom (html), GetDOM = This.getdom (); for (var i = 0, j = dom.length; I < J; i++) {Getdom.parentNode.insertBefore (dom[0], getdom); }}, Remove:function () {this.getdom (). Parentnode.removechild (This.getdom ()); }, Clone:function (id) {var _jiedian = This.getdom (). CloneNode (True); _jiedian.removeattribute ("id"); return _jiedian; }} W.domo = W.domoperation;}) (window);
<! DOCTYPE html>
Dom insertion, removal, cloning