Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

218
Visualizações
Cannot read properties of undefined (reading 'tagName')

I don't know why it's returning error with tagName. is subLabel wrong?

for (var ind = 0; ind < target.length; ind++)
    {
        var target = target[ind]
        for (var ind; ind < target.childNodes.length; ind++);
        {
            const subLabel = target.childNodes[ind];
            if (subLabel.tagName == "SPAN" || subLabel.tagName == "LI") //error line
            {
                //do something with label
            }
            typeDisplay(subLabel);
        }  
    }
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

You are using var ind twice. Use let instead. Read this

about 4 years ago · Juan Pablo Isaza Relatório

0

It's common for nested loops, to use a different loop variable, such as while the outer loop uses var i=0; the inner loop uses var j=0;.

The posted code, the 2nd var ind is duplicated, because it shares the same variable scope of the 1st var.

about 4 years ago · Juan Pablo Isaza Relatório

0

You are using the same variable name in both inner and outer for loop (ie. var ind).

what you can do here is either change the variable name in the inner loop or change the variable name in the outer loop.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda