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

How can I make the hoover area just the immediate surroundings of the "li" items?

I guess this is more a CSS related question, probably using the "event.target.style" proprety and eventually "event.target.style.display", but I would like that the hoover are would be just the surroundings of the li. Currently, if I hoover in the same line of the "li" but really in the right side of the page, it still triggers the event.

Also, it should be inside the if statement of the code:

listDiv.addEventListener('mouseover', (event) => { if (event.target.tagName == 'LI') { event.target.textContent = event.target.textContent.toUpperCase(); } });

correct?

1 Answer

Not really sure what you are trying to accomplish? LI elements are display block and that means that they take up the entire width of their parent element.

Here's a Pen to experiment with that might help. Please notice the background colors to show the actual element.

Also, I used span elements to target just the text. That's just one possible approach.