what\'s wrong with that?
$(\'body\').append(\"\");
$(\'.message\').delay(2000).remove();
<
Using setTimeout() directly (which .delay() uses internally) is simpler here, since .remove() isn't a queued function, overall it should look like this:
$('body').append("");
setTimeout(function() {
$('.message').remove();
}, 2000);
You can give it a try here.
.delay() is for the animation (or whatever named) queue, to use it you'd have to do something like:
$("").appendTo('body')
.delay(2000).queue(function() { $(this).remove(); });
Which works, here...but is just overkill and terribly inefficient, for the sake of chaining IMO. Normally you'd also have to call dequeue or the next function as well, but since you're removing the element anyway...