Javascript code to make image disapear after a a given period of time

I need a code that will either hide a div or an image after a period of time that i will set probably one second or faster if possible.  basically i just want to flash a picture and then have it dissapear.
LVL 1
hibridassassinAsked:
Who is Participating?
 
ZvonkoConnect With a Mentor Systems architectCommented:
For compatibility reasons I would use this one:
<img name="EE" onLoad="setTimeout('document.images.EE.style.display=\'none\';',5000)" src="http://images.experts-exchange.com/images/eeWatermark.png"  >

Open in new window

0
 
quincydudeCommented:
something like setting a timeout and on time out  set the style of the div to hidden
<script language="javascript">
  window.setTimeout("getElementById('xDiv').style.visibility='hidden';", 5000);
</script>

Open in new window

0
 
hibridassassinAuthor Commented:
so is xVid the name of the div?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
hibridassassinAuthor Commented:
also, is 5000 seconds?
0
 
quincydudeCommented:
it should be the id of div, replace it with your own div id and add this to your div by
<div id="mydiv"/> or something like that
0
 
quincydudeCommented:
5000 means 5 seconds
0
 
Michel PlungjanIT ExpertCommented:
and please use
document.getElementById for compatibility reasons
0
 
Michel PlungjanIT ExpertCommented:
Yeah - that would work too, however I think.style is much younger and compatible from getElementById (at least on non-IE)
document.images['EE']

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.