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 trialKeith Grimes
10,263 PointsGetting "null is not an object (evaluating input.value).
When I try to run this code, I keep getting the error message. What am I doing wrong?
btnUpdate.addEventListener("click", () => {
const headline = document.getElementById("headline");
const input = document.querySelector(".input-main"); // this variable is local and only accessible by this function
headline.textContent = input.value; // input.value returns whatever is typed into the input text field
input.value = ""; // this clears the text from the input field textbox
headline.className = "grow"; // this applies the CSS class "grow" to the headline element node
});
1 Answer
Brian Jensen
Treehouse StaffHiya Keith Grimes
It appears that you're just missing the btnUpdate
variable declaration from the starter workspace for the video:
const btnUpdate = document.querySelector('.btn-main');
Awesome code comments!
Keith Grimes
10,263 PointsKeith Grimes
10,263 PointsThank you, Brian.