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 JavaScript and the DOM Making Changes to the DOM Set Inline Styles with the style Property

Cannot read properties of null (reading 'addEventListener')

I used your script from Downloads ("3 - Set Inline Style") . I saved changes in my Workspace and loaded the page. There is an error in the Console :( I don't know what's wrong. Can you please help me?

2 Answers

I prepared a short video to show the error https://www.loom.com/share/2844462b15304dc495c27c8396278118

Rohald van Merode
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Rohald van Merode
Treehouse Staff

Hey Katarzyna Wójtowicz 👋

Looks like there's something wrong in the workspace for this specific video in that it that doesn't completely match with the video. In the workspace the .btn-main element doesn't exist in the DOM. To fix this you'll want to update the button element on line 16 of the index.html file to have a class of btn-main instead of an id 🙂

Sorry for the confusion there, I'll make sure that the workspace will be updated accordingly!