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 trialJonathan Aldas
2,421 PointsIt'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();
}
});
Jonathan Aldas
2,421 PointsYes, I only want to execute the code when I move the mouse on a LI
const listDiv = document.querySelector(".list");
Jonathan Aldas
2,421 PointsNever Mind I found the solution. Thank You
Owa Aquino
19,277 PointsGreat job! So what was it?
Trent Stenoien
Full Stack JavaScript Techdegree Graduate 21,632 PointsLooks 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()).
Owa Aquino
19,277 PointsOwa Aquino
19,277 PointsHi 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!