 <p>Change your HTML to:</p> <pre><code>&lt;div id="content" style="background-color: #E5E5E5; width:500px; height:500px;"&gt; &lt;div class="demo" style="border-style: dashed; background-color: #CCCCCC"&gt; &lt;div class="closebtn"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Then change <code>.demo:before</code> in your CSS to <code>.closebtn</code> and add this to your JavaScript:</p> <pre><code>$('.closebtn').click(function(e) { e.stopPropagation(); $(this).parent().hide(); }); $('#content').click(function(e) { $('.demo').css({top:0,left:0}).show(); }); </code></pre> <p><a href="http://jsfiddle.net/mblase75/g6cdL/48/" rel="nofollow">http://jsfiddle.net/mblase75/g6cdL/48/</a></p>