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

91
Visualizações
Query Selector on multiple pages

let projectTitle = document.getElementById("projectTitle");
projectTitle.textContent = "project";
<div>
    <h1 id="projectTitle">Title</h1>


</div>

I have a website that has multiple pages (all of them are .php). I have a selector in my javascript that selects based on element id and replaces the text but it says in the console that it cannot retrieve the value of null. I used the syntax document.getElementById("projectTitle"). Is there a different way to target the page I want to get the element from or is there something else I'm missing? Also, the header with the links to the .css and .js files are in a separate .php file that is included at the start. The css works. I added a snippet of the code but the issue is not clear as it works perfectly in the snippet. My pages are, however, .php and about 7 of them in the entire website.

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