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

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: