Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

81
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda