Menu
Given the HTML:
[code=html]
<div id=”testing”>
<p class=”clear”></p>
<p class=”d”>
<b>123</b>
</p>
<p class=”e”></p>
<p class=”f”></p>
</div>
And given JS:
[code=php]
family = [];
nodeRec = function(node){
var i;
if(node.hasChildNodes()){
temp = node.childNodes;
for(i=0; i<temp.length; i++){
if(temp[i].nodeType == 1)
family.push(nodeRec(temp[i]));
}
}
return node;
}
I am getting this output:
[code=php]
>>> family
[p.clear, b, p.d]
Maybe this is because I haven’t had my morning coffee yet, but is this a scope problem, and how do I go about fixing my code.
Help appreciated,
Dmitri.