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 trialMarcel Carey
2,890 PointsUncaught TypeError: Cannot read property 'value' of null
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.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="js/app.js"></script>
</body>
</html>
let myHeading = document.getElementById('myHeading')
let myButton = document.getElementById('myButton')
let myTextInput = document.getElementById('myTextInput')
myButton.addEventListener('click',function(){
myHeading.style.color = myTextInput.value
} )
2 Answers
Steven Parker
231,236 PointsThe input element in the HTML has an ID of "MyTextInput" (with capital "M"), but the JavaqScript code is trying to get an element with id of "myTextInput" (lower-case "m").
Marcel Carey
2,890 PointsOH geez. Thanks so much for your help