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

There is a variable named input

Add an ID PhraseText

js/app.js
let button;
let input;
button = document.getElementById("sayPhrase");
input = document.getElementById('PhraseText');
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

Steven Parker
Steven Parker
174,022 Points

This code has "PhraseText" (with a capital "P"), but the instructions call for "phraseText" (with lower-case "p") to match the element that can be seen in the provided HTML code.