日期:2014-05-16 浏览次数:20421 次
alert(getAttrVal("code"))
function getAttrVay(attrName)
{
var obj = a;
for(var i in obj){
if(typeof(obj[i]) == "object" && obj[i] !== null){
getAttrVay(obj[i],attrName)
}else{
if (i == attrName){
return obj[i];
break;
}
}
}
}
a = {
name:"text",
childrenElm:{
parentID:0,
myName:"john",
aihao:{
web:"html",
code:"js"
}
}
}
alert(getAttrVay(a, "code"))
function getAttrVay(obj, attrName)
{
for(var i in obj){
if(typeof(obj[i]) == "object" && obj[i] !== null){
return getAttrVa