Novice here. Working through JavaScript: Novice to Ninja and in Chapter 7 I’m in the Quiz Ninja Project. It has me adding the following to scripts.js:
// Event listeners
$start.addEventListener(‘click’, function() { play(quiz) } , false);
With all the other changes the console (Chrome) keeps reporting:
Uncaught TypeError: Cannot read property ‘addEventListener’ of null
I’ve even gotten the code off of https://github.com/spbooks/jsninja1/ and it gets the same error.
Thanks in advance for any assist.
Hi dlbannerman, welcome to the forum
The $start variable is assigned
var $start = document.getElementById("start");
and “start” is from index.htm
<button id="start">Click to Start</button>
</body>
<script src="js/scripts.js"></script>
if your index.htm file looks like that, try moving the script tag before the closing body tag like so
<button id="start">Click to Start</button>
<script src="js/scripts.js"></script>
</body>
system
Closed
3
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.