Put the remove, specifically it'll be '$(this).remove()', in the
animations callback

http://docs.jquery.com/Effects/animate#paramsdurationeasingcallback



On Oct 10, 6:45 pm, XeroXer <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I am really new to jquery and javascript in general.
> I am making an effort in creating something in the area of a smooth
> thickbox effect with image magnification.
> If people click a link the linked image is opened in an absolute
> positioned div that appears with an animate effect.
> When they close it I want it to animate back the div into nothing and
> then remove it.
> I have then tried using .remove() with no success, well it removes the
> div but before the animate is done.
>
> Code:
> $("#closeThis").click(function () {
>    $("#showThis").animate({width: "0", height: "0"}, "slow");
>    $("#showThis").remove();
>    return false;
>
> });
>
> I have also tried:
> $("#closeThis").click(function () {
>    $("#showThis").animate({width: "0", height: "0"}, "slow").remove();
>    return false;
>
> });
>
> Both with the same result, the div is removed directly at click and
> not after animate.
> Hope that someone can help me fix this problem.
> Or maybe it would be better to always have the div on the page but
> just not visible, not that I know if that would solve my problem but
> maybe it is easier.
>
> Right now:
> $("body").append("<div id='showThis'><p><a href='#'
> id='closeThis'>[close]</a></p><p><img src='"+theLink+"' alt='"+theTitle
> +"'></p></div>");
>
> That is what I use when someone clicks a link, maybe a hidden param in
> css would work just as well.
>
> Well if anyone has any ideas or tips please respond and help me :D

Reply via email to