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!
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
hello everyone Instead of doing myHeading.style.color = myColor.value;
I tried to do declare let colour = myColor.value before the event listener and then using the "colour" variable in the event listener like this
myHeading.style.color = colour;
but nothing happens. Must the .value be inside the event listener function?
I'm assuming you declared the
colour variable outside of the
click event listener. It doesn't work that way, because that runs immediately when the page loads, so the
colour variable will always hold an empty string. If you put the
colour variable inside the
click event listener, it should work since it will only get the value of the input when the button is clicked. Hope this helped!