 <p>I've written spoiler BBCodes for forums before; the concept is essentially the same, so flip them and you get:</p> <pre class="lang-html prettyprint-override"><code>&lt;span&gt; &lt;div onclick="var s=this.parentNode.querySelector('button');s.style.display=s.style.display==''?'none':''"&gt; &lt;!-- put stuff here --&gt; &lt;/div&gt; &lt;button type="button" style="display:none"&gt;&lt;!-- put other stuff here --&gt;&lt;/button&gt; &lt;/span&gt; </code></pre>