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) Making Changes to the DOM Styling Elements

Nicholas Wallen
Nicholas Wallen
12,278 Points

I know what "block" means in regards to CSS, but how did it cause the div to appear and disappear?

toggleList.addEventListener('click', () => { if () { listDiv.style.display = 'block'; } else { listDiv.style.display = 'none'; } });

This question was also asked by someone else, but they didn't get the answer for it either. Just curious.

1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Hi there! As you've pointed out, you know how CSS has different display styles like "inline", "block", etc. If you set the display style to "none" it means that literally. It has no display style which makes it disappear. It is not displayed at all. It's still in the DOM, but has been told not to display.

Hope this helps! :sparkles: