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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Jara larapez](https://secure.gravatar.com/avatar/1fbaff31df3bdd80706758f108fc9fae?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jara larapez
109 PointsmyTextInput is not defined
I have declared the const but the console is saying:
VM323:1 Uncaught ReferenceError: myTextInput is not defined
at <anonymous>:1:1
Here is the code:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript and the DOM</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1 id="myHeading">JavaScript and the DOM</h1>
<p>Making a web page interactive</p>
<input type="text" id="myTextInput">
<button id="myButton">Change headline color</button>
<script src="app.js"></script>
</body>
</html>
const myHeading = document.getElementById('myHeading');
const myButton = document.getElementById('myButton');
const myTextInput = document.getElementById('myTextInput');
myButton.addEventListener('click', () => {
myHeading.style.color = 'red';
});
Which is the problem with mytextInput that makes the console say it's not defined?
Thanks!
![Antonio De Rose](https://secure.gravatar.com/avatar/874005afcfec1528616a756435401c28?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Antonio De Rose
20,885 Points@Adam the suggestion, is a good enough suggestion to go into the answer area, so the other people will also would benefit.
3 Answers
![kols](https://uploads.teamtreehouse.com/production/profile-photos/1206722/micro_Screen_Shot_2016-09-13_at_6.55.30_PM.jpg)
kols
27,007 PointsThe code itself is good. The only thing that raised a similar kind of error that I could replicate (I'm testing in Google Chrome) was when I put the app.js file in its own directory (i.e., a folder named js) and didn't update the link to it in the <script>
tags in the html file to reflect this change.
So, since we can't see your file structure here, that may be something else to double check.
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsIt looks like "myTextInput" is only defined in this code. I don't see any reference to it where that kind of error might be generated. Perhaps there's more of the code than is shown here?
To share the complete project, you can use the "snapshot" function in the workspace and provide the link it creates.
![Steve Kryworuka](https://secure.gravatar.com/avatar/86415352e161529453cedf827f7ea39d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Steve Kryworuka
8,339 PointsI ran into this error. I had previously taken this part of the course but wanted to re-watch and follow along.
I ended up deleting the line in index.html, saving, re-creating, saving again and it worked. There were no typos. Just in case someone else runs into that and can't find any other options.
Adam Beer
11,314 PointsAdam Beer
11,314 PointsI checked your code, and it's the good code. My console was clean. I don't have idea why told to you "it's not defined".
Ps.: Use the Markdown Cheatsheets
Code
Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.