0

I wrote this code in my html file <button onclick="startGame" class="startBtn">Start</button>

And this in my JavaScript


var start = document.querySelector(".starter");

var game = document.querySelector(".game");

var submit = document.querySelector(".submit");

function startGame() {

  start.classList.add("hide");

  game.classList.remove("hide");

}

But when I run this it shows the error like this enter image description here

I tried to hide an element and show another with this function. But return the error

1 Answers1

0

looks like start variabel didn't find your element. try console.log(start) to check does it get the html element or not

cloe
  • 1
  • 1