jQuery: append() object, remove() it with delay()

前端 未结 4 1495
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 06:09

what\'s wrong with that?

$(\'body\').append(\"
Upload successful!
\"); $(\'.message\').delay(2000).remove(); <
4条回答
  •  春和景丽
    2020-12-01 06:34

    Maybe I'm using an outdated jQuery, but none of the methods suggested in other answers seem to work for me. According to http://api.jquery.com/delay/ , delay is for animation effects.

    Using setTimeout() however, works nicely for me:

    $('body').append("
    Upload successful!
    "); setTimeout(function(){ $(".message").remove(); }, 2000);

提交回复
热议问题