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

301
Visualizações
Uncaught TypeError: Cannot read properties of null (reading 'appendChild'); Persistent Error

My script tag is at the bottom of my body tag which is the main solution I have found on here. Is there any other reasons appendChild would be running into this error?

Html:

     <section class="section-2">
       <p class="about-me-text"></p>
     </section>
     <script src="rScript.js"></script>
   </body>

Javascript:

const aboutMeText = document.querySelector("about-me-text");
const aboutMeTextContent = 'I am a creative designer, who dabbles in both website 
creation & digital art design. Contact me to start a creative project or website 
today.'

Array.from(aboutMeTextContent).forEach(char => {
 const span = document.createElement("span");
 span.textContent = char;
 aboutMeText.appendChild(span);
})
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You need to add a "." to querySelector() when targeting a class name.

const aboutMeText = document.querySelector(".about-me-text");
const aboutMeTextContent = `I am a creative designer, who dabbles in both website
  creation & digital art design. Contact me to start a creative project or website
  today.`

Array.from(aboutMeTextContent).forEach(char => {
  const span = document.createElement("span");
  span.textContent = char;
  aboutMeText.appendChild(span);
})
<section class="section-2">
  <p class="about-me-text"></p>
</section>

about 4 years ago · Juan Pablo Isaza Relatório

0

When using querySelector, you have to clarify which element are you selecting, for example, in your problem as you're selecting a class, you have to put a . in the start of about-me-text. For a ID, you'll add a # at the start, etc.

const aboutMeText = document.querySelector(".about-me-text");
const aboutMeTextContent = 'I am a creative designer, who dabbles in both website creation & digital art design. Contact me to start a creative project or website today.'

Array.from(aboutMeTextContent).forEach(char => {
 const span = document.createElement("span");
 span.textContent = char;
 aboutMeText.appendChild(span);
})
<section class="section-2">
       <p class="about-me-text"></p>
     </section>
     <script src="rScript.js"></script>
   </body>

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