Now You See It, Now You Don’t: Two Ways To Toggle Using Vanilla JavaScript
Nov 8 · 5 min read
In this tutorial, I walk through two methods you could use to change the content of a webpage by manipulating the Document-Object Model (“DOM”) in response to user click events.
Here’s what we’re looking to achieve:
- On the load of a page, a user should see a button that says “Show Dog”
- When the button is clicked, an
<img> element should be toggled on and appear on the page. The text of the button should also toggle to “Hide Dog”


