This article mainly introduced JS use for loop coordinate array traversal child node lookup element
function Nextchildnode (node,clazz,tagname) {
var count= node.childelementcount;
for (Var i=0;i<count;i++) {
if (node==undefined | | node.children[i]==undefined) {
continue;
}
if (clazz) {
if (Node.children[i].getattribute (' class ') ==clazz) {return
node.children[i];
}
} else{
if (node.children[i].tagname==tagname) {return
node.children[i];
}
}} return null;
}
function Getchildnode (node,classarg,tagnodearg) {for
(var i=0;i<classarg.length;i++) {
node= Nextchildnode (Node,classarg[i]);
for (Var i=0;i<tagnodearg.length;i++) {
node=nextchildnode (node,null,tagnodearg[i]);
}
return node;
}
function Getitemid (node) {
var classnode=[' iteminfo ', ' Itemdesc '],tagnode=[' P ', ' BUTTON '];
Node=getchildnode (Node,classnode,tagnode);
Alert (Node.getattribute (' itemid '));
}
#调用函数