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

Robbie Thomas
Robbie Thomas
31,091 Points

Selecting by ID: Challenge 1 of 2

Been on this for twenty minutes and still stumped, any help is appreciated.

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

2 Answers

Adam Beer
Adam Beer
11,269 Points

Please fixed your code. You misspelled. What you wrote.

document.getElementbyId

but the correct code is the

document.getElementById

That's b with upper case. Hope this help.

Robbie Thomas
Robbie Thomas
31,091 Points

Forget it, found out the problem. For one thing, that let input shouldn't have that for part 1. And also, I forgot to use a capital B for getElementById in the first line.