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

Nicholas Wallen
Nicholas Wallen
12,278 Points

No idea why this isn't working. My answer is correct.

let input = document.getElementById("phraseText");

That is the correct answer. Its not working.

js/app.js
let input = document.getElementbyId('phraseText');
let button = document.getElementById('sayPhrase');
console.log(button); 

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

trio interactive
trio interactive
15,321 Points

Hey!

You seem to have misspelled the getElementById in the first line (lowercase b should be capital B). Otherwise your code is passing.

Nicholas Wallen
Nicholas Wallen
12,278 Points

How come it requires "console.log(button); " That wasn't discussed in the videos.

Antti Lylander
Antti Lylander
9,660 Points

No, it certainly does not require console.log to pass.