Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM Making Changes to the DOM Change Element Attributes

Keith Grimes
Keith Grimes
9,503 Points

Getting "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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Brian Jensen
Treehouse Staff

Hiya Keith Grimes :wave:

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! :fire: