Question:

Tutorial for setTimeout javascript

by  |  earlier

0 LIKES UnLike

Hey Everyone,

I was wondering if anyone knew of a good tutorial for javascript's setTimeout? What i am basically trying to do is get a div to appear, disappear and reappear. However, i can not seem to get the div to appear.

I click this to make it appear <input type="button" class="resubmitform1"

value="Resubmit Form 1"

onclick="javascript:get

(this.parentNode);" >

this is what makes it disappear

setTimeout("document.

getElementById('myspan').

style.display='none';", 9000);

just can't figure out how to make it reappear.

Thank you to all who help,

Rach

 Tags:

   Report

1 ANSWERS


  1. setTimeout works well with functions...  I am not sure why yours is not working, but try it like this.  I tested it, it works fine.

    ========

    &lt;html&gt;

    &lt;head&gt;

      &lt;script type=&quot;text/javascript&quot;&gt;

        function showMagicDiv() {

          document.getElementById( &quot;magic_div&quot; ).style.display = &#039;block&#039;;

          setTimeout(&quot;hideMagicDiv()&quot;, 2000);

        }

        

        function hideMagicDiv() {

          document.getElementById( &quot;magic_div&quot; ).style.display = &#039;none&#039;;

        }

      &lt;/script&gt;

    &lt;/head&gt;

    &lt;body&gt;

    &lt;/body&gt;

    &lt;input type=&quot;button&quot; class=&quot;resubmitform1&quot;

    value=&quot;Show Div&quot;

    onclick=&quot;showMagicDiv();&quot; &gt;

    &lt;div id=&quot;magic_div&quot; style= &quot;display:none; padding:15px; background-color:blue; color:yellow&quot; &gt;This is the magic div&lt;/div&gt;

    &lt;/html&gt;

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.