贴上相关代码
获取元素子节点-兼容低版本浏览器window.οnlοad=function(){
var oUl=document.getElementById("ul1");
var op=document.getElementById("p1");
function getEleChild(ele){
var eleChildArr=ele.children || ele.childNodes;
var childArrTmp=[];
for(var i=0;i
if(eleChildArr[i].nodeType==1){
childArrTmp.push(eleChildArr[i]);
}
}
return childArrTmp;
}
console.log(getEleChild(op));
console.log(getEleChild(oUl));
alert(getEleChild(op).length);
alert(getEleChild(oUl).length);
}
1111
li之前的span标签
li之前的span标签
li之后的span标签
2222