日期:2014-05-16  浏览次数:20304 次

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) {
1 楼 lxc914_java 2011-09-24  

<script>
var object={name:'sa bi sang yiang',age:22,address:'beijing',id:'sa bi id'};
for(var key in object){
alert(object[key]);
}
</script>

回来请吃饭。