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?
The correct syntax is
<script src= script.js></script>
Then you can do -->
let ex = document.querySelector('.test1').innerHTML = "Hello World!";