jQuery : remove element except inside element
<p>Is there any way to remove element except inside element:</p>

<pre><code>&lt;div class="gallery"&gt;
  &lt;a href="images/rep.png" title="rep"&gt;
    &lt;img src="http://example.com/uploads/rep.png" class="thumbnail" alt="rep" title="rep"&gt;
  &lt;/a&gt;
&lt;/div&gt;
</code></pre>

<p>to</p>

<pre><code>&lt;div class="gallery"&gt;
  &lt;img src="http://example.com/uploads/rep.png" class="thumbnail" alt="rep" title="rep"&gt;
&lt;/div&gt;
</code></pre>

<p>I wrote this code but not work:</p>

<pre><code>$(".gallery").contents().filter(".thumbnail").remove();
</code></pre>
