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 (Retiring) Getting a Handle on the DOM A Simple Example

Tim Brooks
Tim Brooks
2,339 Points

DOM selection: can't get heading to turn red

I think I've followed directions in the tutorial exactly, but get no color change from

const myHeading = document.GetElementById('myHeading');

myHeading.addEventListener('click', () => { myHeading.style.color = 'yellow';
});

Here's my snapshot. If it says yellow, that's because I'm a bit colorblind.

Tim Brooks
Tim Brooks
2,339 Points

Link to snapshot: const myHeading = document.GetElementById('myHeading');

myHeading.addEventListener('click', () => { myHeading.style.color = 'yellow';
});

https://w.trhou.se/conkaqzvhr

3 Answers

Hey Tim Brooks,

Looks like you have capitalized letter g whilst selecting myHeading.

const myHeading = document.getElementById('myHeading');

Hope this helps!

Tim Brooks
Tim Brooks
2,339 Points

ah, thank you both. I see it now

Doak Covington
Doak Covington
4,644 Points

A helpful tool to using for these types of lessons is https://codepen.io/

It gives you a better picture of whats going on then workspaces.

Doak Covington
Doak Covington
4,644 Points

Hi Tim,

You need to camel case GetElementById

Tim Brooks
Tim Brooks
2,339 Points

Looks to me like I did already