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

369
Visualizações
innerHTML error in syntax not working; Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')

For some reason I am keep on getting a syntax error from this "innerHTML", can someone help me?

HTML CODE:

<div id="ID"></div>

JavaScript CODE:

document.getElementById("ID").innerHTML = "Test";

Syntax Error: Uncaught TypeError: Cannot set properties of null (setting 'innerHTML')

I am trying to make the div respond with a "Test" using "innerHTML" and "getElementById" but the syntax error is getting in the way.

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

The error means that js not found with the selector ID. You need ID as a selector. Take a look:

document.getElementById("ID").innerHTML = "Test";
<div id="ID">Hello</div>

about 4 years ago · Juan Pablo Isaza Relatório

0

The error refers to the fact that document.getElementById("ID") is invalid. Meaning that "ID" is not existing. In your HTML code there needs to be an object with the id="ID".

about 4 years ago · Juan Pablo Isaza Relatório

0

Running getElementById on an ID that isn't currently existing on the webpage will give you this error, if you are working on a project with multiple scenes and you try to call this for an element on a scene that is NOT currently shown on the screen it will error out with this error.

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