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

Sufia Shahnawaz
Sufia Shahnawaz
544 Points

I have inputted my answer into the javascript doc and I don't know what is incorrect about it?

var button= document.getElementbyId('sayPhrase');

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

2 Answers

<noob />
<noob />
16,367 Points

Hi! you have a very small problem. look at your getElementbyId tag, it should be getElementById with a capital B

Sufia Shahnawaz
Sufia Shahnawaz
544 Points

Ah- thank you :D Always the tiny things that pass unseen.