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 AJAX Basics AJAX Concepts A Simple AJAX Example

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.

1 Answer

Steven Parker
Steven Parker
229,968 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.