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!
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
Another way to make the button disappear
I tried to make the button before watching the video and accidentally stumbled on another way to make the button disappear without setting the display to none.
If you place the button element:
<button id="load" onclick="myButton()">Load Page!</button>
Inside the div with the id
"ajax", the callback function will automatically overwrite the
innerHTML of that div with the callback function content and the button disappears.
Is there any considerations with this method? I'm thinking using the display = none method makes the button display "reversible" so that one could make the button appears again for whatever reason in the future.
Steven Parker224,924 Points
There are many ways to delete an element, any of them could be used to make the button go away permanently.
But as you observed, an advantage of setting the "display" style is that is can be reversed later if you want the button to re-appear.