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

151
Visualizações
Cannot read properties of undefined (beginner question)

So I have got this error saying 'Uncaught TypeError: Cannot read properties of undefined (reading 'style')' on line 97, a.style.textDecoration = 'line-through'; Can someone explain to me why it happened? I think I had 'a' defined in the same function. Thank you in advance!

I am trying to write a to do list. And when I click on the checkbox in front of the task, the task would be crossed out. Here is the code of the function with error...

function crossing(x){
    array1.forEach(function process(y){
        const a = document.getElementById(y.code).getElementsByTagName('div')[0];
        if(y.code===x.target.id){
            **a.style.textDecoration = 'line-through';**
        }
    })
}

Here is the link for all the codes... https://jsfiddle.net/PhilipWoo/x8dewa0s/

about 4 years ago · Juan Pablo Isaza
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