Este artigo apresenta principalmente JS usando um loop para pesquisar elementos com uma travessia de matriz de nós filhos
função nextChildNode (nó, clazz, tagname) {var count = node.childElementCount; for (var i = 0; i <contagem; i ++) {if (node == indefinido || node.children [i] == indefinido) {continuação; } if (clazz) {if (node.children [i] .getAttribute ('class') == clazz) {return node.children [i]; }} else {if (node.children [i] .TagName == tagName) {return node.children [i]; }}} retornar nulo; } função getChildNode (nó, classarg, tagnodearg) {for (var i = 0; i <classarg.length; i ++) {node = nextChildNode (node, classarg [i]); } para (var i = 0; i <tagnodearg.length; i ++) {node = nextChildNode (nó, nulo, tagnodearg [i]); } retornar o nó; } função getItemid (nó) {var classNode = ['itemInfo', 'itemDesc'], tagnode = ['p', 'botão']; node = getChildNode (nó, classNode, tagNode); alerta (node.getAttribute ('itemId')); } #Calando a função getItemid ($ (". Shopitem") [0]);