js方法(5)

var div = this.ownerDocument.createElement("div");
div.innerHTML = obj;
var elem = div.childNodes;
var ret = [];
for (var e in elem) {
if (elem[e].nodeType === 1) {
ret.push(elem[e]);
}
}
for (var i = 0; i < ret.length; i++) {
this.appendChild(ret[i]);
}
}, content);
}
}
}, appendTo:function (e) {
if (typeof e === "string" && e !== undefined) {
var obj = [];
for (var i = 0; i < this.length; i++) {
obj.push(this[i]);
}
var es = this.init(e);
this.addElement(es, function (param) {
this.appendChild(param.cloneNode(true));
}, obj);
this.empty(obj);
return this;
}
}, addElement:function (object, callback, params) {
for (var j = 0; j < object.length; j++) {
for (var i = 0; i < params.length; i++) {
callback.call(object[j], params[i]);
}
}
}, bind:function (E, fn) {
if (typeof E === "string" && typeof fn === "function") {
if (window.addEventListener) {
this.each(this, function (fn) {
this.addEventListener(E, fn, false);
}, fn);
} else {
if (window.attachEvent) {
this.each(this, function (fn) {
this.attachEvent("on" + E, fn);
}, fn);
}
}
}
}, addClass:function (styles) {
if (typeof styles === "string") {
for (var i = 0; i < this.length; i++) {
styles += " " + this[i].className;
this[i].className = styles;
}
}
return this;
}, removeClass:function (styles) {

你可能感兴趣的:(js)