Este artículo presenta principalmente JS usando un bucle para los elementos de bucle para buscar con un recorrido de la matriz de nodos infantiles
función nextChildNode (nodo, clazz, tagName) {var count = node.childelementCount; for (var i = 0; i <count; i ++) {if (node == Undefined || node.children [i] == undefined) {continuar; } 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; } función getChildNode (nodo, classarg, tagNodearg) {for (var i = 0; i <classarg.length; i ++) {node = nextChildNode (nodo, classarg [i]); } for (var i = 0; i <tagNodearg.length; i ++) {node = nextChildNode (nodo, null, tagNodearg [i]); } nodo de retorno; } función getItemid (nodo) {var classNode = ['itemInfo', 'itemDesc'], tagNode = ['P', 'Button']; nodo = getChildNode (nodo, classnode, tagNode); alert (node.getAttribute ('itemID')); } #Calling la función getItemid ($ (". ShopItem") [0]);