Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM Selecting by Id

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>

2 Answers

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

what is the goal of select the input element with the ID phraseText and assign it to the input variable. Guil talks a lot in the videos but when the exercices come i dont know what to do because they look different from what i saw..