jquery .remove not working as expected
<p>I have the following which is supposed to remove the element ".mycontainer" when I click on a close button. It's not removing the element though. When I use firebug. I can see that it is just moving it to outside of the html tags at the beginning on the code.</p>

<pre><code>    $('.closeButton').click( function() {
       $(".mycontainer").slideUp( function() {
           $(".closeButton").parent().appendTo(".ContentsHolder");        
           $(this).remove();
       });
    });
</code></pre>

<p>It works if I comment out the 3rd line <code>//$(".closeButton").parent().appendTo(".ContentsHolder");</code></p>

<p>but this removes the content so I can't access it again.</p>

<p>EDIT:</p>

<p>My html looks something like this if it helps to understand what I'm doing...</p>

<pre><code>&lt;div class='ContentsHolder'&gt;

&lt;/div&gt;
&lt;div class='mycontainer'&gt;
    &lt;div class='myContent'&gt;
        &lt;a class='closebutton'&gt;close&lt;/a&gt;
        ... other content ...
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>I have also managed to make it work by putting a delay on the removal of mycontainer <code>$(this).delay(500).remove();</code></p>

<p>I would not think this is a great solution though.</p>
