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

119
Views
unable to access a element in different html file

I have 2 html file and one js file.

index.html

<h1 class="test">This is a test</h1>
<style src= script.js></script>

home.html

<h1 class="test1">This is a test</h1>
<style src= script.js></script>

script.js

let ex = document.querySelector('.test1')
console.log(ex) 

//cannot read properties of null.

how can access h1 from home.html?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The correct syntax is

<script src= script.js></script>

Then you can do -->

let ex = document.querySelector('.test1').innerHTML = "Hello World!";
about 4 years ago · Juan Pablo Isaza Report
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!