Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

80
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!