Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM 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 20,034 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()).