what\'s wrong with that?
$(\'body\').append(\"
\");
$(\'.message\').delay(2000).remove();
<
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("
");
setTimeout(function(){
$(".message").remove();
}, 2000);