Hi everyone
I am working on the portfolio project for Javascript and I am going around the bend trying to work out why it is not working.
My index.html page has a link to main.js and then in the body of the page the following:
<button id="test-button">This is a test</button>
<p id="test-para">A test goes here</p>
Then in main.js I have the following:
let itemOne = document.querySelector("test-button");
let itemTwo = document.querySelector("test-para");
function changeBackground() {
itemTwo.style.backgroundColor = "blue";
}
itemOne.addEventListener('click', changeBackground);
I have tried about fifty iterations of this and nothing is working. However, I know the Javascript file is linked properly because I can get it to display an alert window.
Any troubleshooting tips for this extraordinarily frustrated newbie?