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) Responding to User Interaction The Event Object

Jonathan Aldas
Jonathan Aldas
2,421 Points

It's not working.

it's selecting the correct tag because it spits it out to the console but it does not want to work?

listDiv.addEventListener("mouseover", (e) => {

  if(e.target.tagName == 'LI'){
  console.log(e.target.tagName);
    e.target = e.target.textContent.toUpperCase();
  }
});
listDiv.addEventListener("mouseout", (e) => {
  if(e.target.tagName == 'LI'){
  console.log(e.target.tagName);
    e.target = e.target.textContent.toUpperCase();
  }
});
Owa Aquino
Owa Aquino
19,277 Points

Hi Jonathan,

Can you add how you selected the listDiv on your code. That will much help us to understand your problem.

And is there any reason why you have the same condition when you mouseover and mouseout?

Cheers!

Jonathan Aldas
Jonathan Aldas
2,421 Points

Yes, I only want to execute the code when I move the mouse on a LI

const listDiv = document.querySelector(".list");
Jonathan Aldas
Jonathan Aldas
2,421 Points

Never Mind I found the solution. Thank You

Owa Aquino
Owa Aquino
19,277 Points

Great job! So what was it?

Trent Stenoien
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Trent Stenoien
Full Stack JavaScript Techdegree Graduate 21,632 Points

Looks like you already found the answer, but here's the solution for anyone else wondering. I believe so anyway.... haha!

Right now you are redefining the entire e.target object; you need to be more specific. If you add '.textContent' before the = you will have better results.

listDiv.addEventListener("mouseout", (e) => {
    if(e.target.tagName == 'LI'){
        e.target.textContent = e.target.textContent.toUpperCase();
    }
});

Some methods will return a value you need to store in a new variable (like this one), others will just modify the thing you're calling it on (like document.write()).