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

myTextInput returns null in the browser console.

Hi all,

So I am using Opera to work on this course and as I as working through, Guil types in myTextInput and shows that it is hoverable. When I typed myTextInput into the concole, and hit enter it returns a value of null.

Have I missed something? Or is Opera not the most compatible with Worksaces?

Here is a snapshot of my code: https://w.trhou.se/b9lddypj8y

Any help or insight would be appreciated.

2 Answers

Grzegorz Zielinski
Grzegorz Zielinski
5,838 Points

You've made a small mistake in your HTML file

<!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 id="text" id="myTextInput"> <!-- input has two IDs. I belive first attribute should not be an "id" but "type" (type="text"). -->
    <button id="myButton">Make Heading Red</button>
    <script src="app.js"></script>
  </body>
</html>

When you fix that everything should work fine.

Hope it helps!

Hi Grzegorz,

Ah thank you. Looking back through the video the first attribute is type not id. I must have gotten mixed up.

Well Spotted!

Mark