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 (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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
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: