有人知道如何显示[object HTMLUListElement]的元素吗?
感谢,
布鲁诺
答案 0 :(得分:3)
假设您想要子节点:
var lis = theObject.children;
for(var i = 0; i < lis.length; i++) {
console.log(lis[i].innerHTML);
}
答案 1 :(得分:0)
尝试以下方法:
var myObj; //I'm assuming this variable contains your HTMLUListElement
for (var member in myObj){
alert(myObj[member]);
}
使用for时,你应该检查hasOwnProperty
,不过
for (var member in myObj){
if (myObj.hasOwnProperty(member)){
alert(myObj[member]);
}
}