I'm writing a code on speed typing test, and I would like to start the timer when the user inputs the texteare for the first time. However, the textarea doesn't seem to be logging in my input changes and console is returning an error message saying addEventListener cannot return a property of null.
HTML CODE
<section class="typing">
<div class="timer" id="timer"><h1>60</h1></div>
<div class="container">
<div class="word-display" id="word-display">
<p>Typing Test</p>
</div>
<textarea id="word-input" class="word-input" rows="7" placeholder="Start Typing" name="word-input"></textarea>
</div>
</section>
JAVA CODE
function startTimer() {
startTime = new Date();
setInterval(() => {
document.querySelector('#timer').innerText = getTimerTime()}, 1000);
};
function getTimerTime () {
return (60 - Math.floor((new Date() - startTime) / 1000));
};
document.querySelector('DOMContentLoaded', onload = generateWordSpan, onkeyup = checkWord, function() {
if (document.querySelector('#word-input')) {
document.querySelector('#word-input').addEventListener('onchange', startTimer, {once: true})
};
});