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

Clifford Angat
Clifford Angat
72 Points

Bummer: There was an error with your code: TypeError: 'undefined' is not a function (evaluating 'document.GetElementById

Bummer: There was an error with your code: TypeError: 'undefined' is not a function (evaluating 'document.GetElementById('myTextInput')')

js/app.js
var button = document.getElementById('sayPhrase');
var phraseText = document.GetElementById('myTextInput');


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,926 Points

Task 2 instructions: Next, select the input element with the ID phraseText and assign it to the input variable.

You have a few issues:

  • you changed the variable name from input to phraseText
  • the g in getElementById should be lowercase
  • the id to select is phraseText not myTextInput