Link to home
Start Free TrialLog in
Avatar of hibridassassin
hibridassassinFlag for United States of America

asked on

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.
Avatar of quincydude
quincydude
Flag of Hong Kong image

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

Avatar of hibridassassin

ASKER

so is xVid the name of the div?
also, is 5000 seconds?
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
5000 means 5 seconds
Avatar of Michel Plungjan
and please use
document.getElementById for compatibility reasons
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah - that would work too, however I think.style is much younger and compatible from getElementById (at least on non-IE)
document.images['EE']