var arr = [ {"id":"10", "class": "child-of-9"}, {"id":"11", "classd": "child-of-10"}];
for (var i = 0; i < arr.length; i++){
var obj = arr[i];
for (var key in obj){
var attrName = key;
var attrValue = obj[key];
}
}
var arr = [ {"id":"10", "class": "child-of-9"}, {"id":"11", "class": "child-of-10"}]; for (var i = 0; i < arr.length; i++){ document.write("<br><br>array index: " + i); var obj = arr[i]; for (var key in obj){ var value = obj[key]; document.write("<br> - " + key + ": " + value); } }
note: the for-in method is cool for simple objects.
(注意:for-in方法对于简单对象很酷。)
Not very smart to use with DOM object. (与DOM对象配合使用不是很聪明。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…