I'm designing a quiz app, but while console logging for a click event, this statement showed up on the console. Code -
startButton.addEventListener("click", function startGame() {
console.log("started");
});
what should i do to show the statement on my console???
If you get this error it means that your start button is null. 2 possibilities:
Your selector for startButton is incorrect. So you have to adjust your selector.
Your selector is correct but your button is not in the DOM yet. So you have a problem with timing. Try to add the eventlistener at the end of your code