JS获取节点属性个数及值得方法
var ex = node; var str = "ex"; var myIndex = 1; for (var j in ex) { alert("" + myIndex + "、(<font color='blue'>" + typeof (eval(str + "." + j)) + "</font>)<font color='red'>" + j + "</font>" + ":"); try { alert("<font color=''>" + eval(str + "." + j) + "</font>" + "<br>"); } catch (e) { } myIndex++; }
var str = "ex"; var myIndex = 1; for (var j in ex) { document.writeln("" + myIndex + "、(<font color='blue'>" + typeof (eval(str + "." + j)) + "</font>)<font color='red'>" + j + "</font>" + ":"); try { document.writeln("<font color=''>" + eval(str + "." + j) + "</font>" + "<br>"); } catch (e) { } myIndex++; } return;
直接显示出来(亲自试一试?): var node = new Image(); var NewDivNode = $("<div></div>"); var str = "node"; var myIndex = 1; for (var j in node) {try {var curStr1 = "错误"; var curStr2 = "错误"; try {curStr1 = typeof (eval(str + "." + j)); curStr2 = eval(str + "." + j);} catch (e) {}NewDivNode.append("" + myIndex + "、(<font color='blue'>" + curStr1 + "</font>)<font color='red'>" + j + "</font>" + ":");NewDivNode.append("<font color=''>" + curStr2 + "</font>" + "<br>");}catch (e) {} myIndex++;} $("body").html(NewDivNode);