Newbie
Newbie

Reputation: 8605

How to show an image and hide it after 5 seconds?

var div=document.createElement("div");
div.innerHTML="<img src='load.gif'>";

With javascript.

Upvotes: 1

Views: 3370

Answers (2)

BalusC
BalusC

Reputation: 1108712

Make use of setTimeout().

Edit: I realize, isn't this a bit fake? Shouldn't you hide a load.gif when the loading task is actually finished? Using them for decoration only makes no sense.

Upvotes: 3

Piotr Rochala
Piotr Rochala

Reputation: 7781

I would use jQuery for it so code is more elegant. Otherwise you could use setTimeout

var div=document.createElement("div");
div.innerHTML="<img src='load.gif'>";
setTimeout("div.innerHTML=''",5000);

Upvotes: 0

Related Questions