JavaScript JavaScript and the DOM Getting a Handle on the DOM Selecting by Id

Natasha Harrington
Natasha Harrington
11,365 Points

I can't figure out what's wrong with this code.

I can not figure out what is wrong with this code. It tells me undefined is not a function?

var button = document.getElementByID('sayPhrase');
var input;

button.addEventListener('click', () => {
<!DOCTYPE html>
    <title>Phrase Sayer</title>
    <p><input type="text" id="phraseText"></p>
    <p><button id="sayPhrase">Say Phrase</button></p>
    <script src="js/app.js"></script>

1 Answer