Onclick show Image or DIV and hide automatically..
Hi, I am looking to show the image or DIV when clicked and hide it automatically (after specific time). It sounds like simple however I Googled for it but nothing found. So, I am hoping I will get something here in this genius JS programmers forum.
Any scripts example would be highly appreciated. (Please make it simple)
I don't completely follow. It has to be shown in order to be clicked, so it's already shown. You can automatically hide anything by using setTimeout("function",x); where x is the number of milliseconds (1000 per second) to call the function.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
I don't completely follow. It has to be shown in order to be clicked, so it's already shown. You can automatically hide anything by using setTimeout("function",x); where x is the number of milliseconds (1000 per second) to call the function.
Thanks for your response. I am new to JS as you can see the code below:
I have tried above code and it works for showing the hidden DIV however it doesn't automatically hide the DIV. As I don't know where to specify following code for hiding the DIV?
Code:
document.getElementById(o).style.display='none';
Thanks!!
Last edited by djnp; 06-28-2012 at 08:33 PM..
Reason: to make it more clear
You placed the setTimeout that calls a function within the function, so it loops; every 2 seconds, it sets the display to "block".
To stop the setTimeout, you need to set it to a variable and use clearTimeout on the variable.
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".