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

Michael Zeta
Michael Zeta
15,838 Points

This should be right. I think Treehouse be trippin.

Says there is "an error evaluating document.getElementByID('sayPhrase');" Why? Seems like I have the correct syntax and spelling. Am I missing something?

js/app.js
let button = document.getElementByID('sayPhrase');
let input;

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

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,890 Points

The D in ID is lowercase. It should be

let button = document.getElementById('sayPhrase');