View Full Version : Showing Hidden Elements (RESOLVED)

Mar 14th, 2008, 08:37 PM
I'm new to javascript, so forgive me if this question is too basic.
I'm trying to show an HTML element after a several second delay.
I used the following code to make an element hide:
<script language="javascript">
var timerID;
function ShowLayer(id){ document.getElementById().style.display = "block"; }
function HideTimedLayer(id){ clearTimeout(timerID); document.getElementById(id).style.display = "none"; }
function timedLayer(id){ setTimeout("HideTimedLayer(\"" + id + "\")", 2500); }
How would I customize this to show an already hidden element?

Thanks in Advance!

Mar 14th, 2008, 10:08 PM
Like this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function showDiv(id){
var obj = document.getElementById(id);
<div id="mydiv" style="display:none">MY div</div>
<span onclick="setTimeout(function(){showDiv('mydiv')},2500)">Show me the div</span>

Mar 15th, 2008, 04:12 AM
Thank you Kor. That did the trick!