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

Su Deng
Su Deng
1,226 Points

toggle button

i dont understand how on this video, if we make the button text content as hide list, why do we code style.display = block? if we wanna hide it shouldn't it be = none instead?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It's because the button should read "Hide List" when the block is displayed, not when it's hidden. When the block has a style of "none", it is hidden and then we want the button to say "Show List". It would be odd to have a "Hide List" button when there's no list visible, right? :smiley:

Hope this helps! :sparkles: