<body>
<p id="ap">
<h1>name</h1><p>contentcontentcontent<span>content</span></p></p>
<script>
var someElement={
children:function(element){
if(element.children){
console.log(element.children);
} else {
var i,
len=element.childNodes.length;
for(i=0;i<len;i++){
if(element.childNodes[i].nodeTypoe == 1){
element.childNodes[i];//怎样把得到的元素节点放在一起,之前搜过,说是放在数组里,可那个不是HTMLCollection啊。
}
}
}
}
};
var p = document.getElementById("ap");
someElement.children(p);
</script>
</body>
仅有的幸福2017-05-19 10:24:40
To shield the compatibility issues of browser DOM operations, jquery is still the first choice