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 Ambriz
Courses Plus Student 3,902 PointsHide/Show button replaces HTML with one line of all text instead of what was there previously.
When I use the Hide/Show buttons, it replaces the text in the lower half to the webpage with one line of code.. I'm not sure what I can do to get it to show all the content as it was previously. It all goes to uppercase/lowercase when the mouse hovers over it, instead of each individual item. The snapshot is HTTP://w.trhou.se/j0e5uwzi1e
Can you explain what is wrong with my code?
1 Answer
Heidi Fryzell
Front End Web Development Treehouse Moderator 25,178 PointsHi Jonathan,
I found a couple little things in your code that were causing some issues.
const removeItemButon = document.querySelector('button.removeItemButton');
The variable name above is missing the second "t" in removeItemButton.
In your If conditional statement to check for list items you want to use "==" not "=". The single "=" is the assignment operator. The "==" checks for equality.
Here is how the if statements should look:
listDiv.addEventListener('mouseover', (event) => {
if (event.target.tagName == 'LI'){
event.target.textContent = event.target.textContent.toUpperCase()
}});
listDiv.addEventListener('mouseout', (event) => {
if (event.target.tagName == 'LI'){
event.target.textContent = event.target.textContent.toLowerCase()
}});
Hope this helps and happy coding!
Jonathan Hermansen
25,935 PointsJonathan Hermansen
25,935 PointsA couple of things..
In index.html
In app.js: