Note that there are some explanatory texts on larger screens.

plurals
  1. POPause Javascript for a few seconds on click
    primarykey
    data
    text
    <p>Ok i know this has to be a topic discussed earlier, but all the answers I found were a little complicated considering I'm new and still in the process of learning javascript.</p> <p>I have the following code in the head section of my html</p> <pre><code>&lt;script&gt; function timedText() { setTimeout(function(){displayResult()},3000); setTimeout(function(){displayResult1()},7000); setTimeout(function(){displayResult2()},15000); setTimeout(function(){timedText()},18000); } &lt;/script&gt; &lt;script&gt; function change() { setTimeout(function(){timedText()},1000); } &lt;/script&gt; &lt;script&gt; function displayResult() { document.getElementById("adimg_holder").style.bottom="0px"; document.getElementById("button1").style.backgroundPosition="bottom"; document.getElementById("button2").style.backgroundPosition="top"; document.getElementById("button3").style.backgroundPosition="top"; } function displayResult1() { document.getElementById("adimg_holder").style.bottom="370px"; document.getElementById("button1").style.backgroundPosition="top"; document.getElementById("button2").style.backgroundPosition="bottom"; document.getElementById("button3").style.backgroundPosition="top"; } function displayResult2() { document.getElementById("adimg_holder").style.bottom="739px"; document.getElementById("button1").style.backgroundPosition="top"; document.getElementById("button2").style.backgroundPosition="top"; document.getElementById("button3").style.backgroundPosition="bottom"; } &lt;/script&gt; </code></pre> <p>and the following html</p> <pre><code> &lt;body onload="change()"&gt; &lt;div class="banner_area"&gt; &lt;div class="banner_wrapper"&gt; &lt;img src="images/image_holder.png" /&gt; &lt;div id="ad_holder"&gt; &lt;div id="adimg_holder"&gt; &lt;img class="ad_images" src="images/recruitment_banners.png" /&gt; &lt;img class="ad_images" src="images/training_banners.png" /&gt; &lt;img class="ad_images" src="images/staffing_banner.png" /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="ad_buttons"&gt; &lt;div id="button1" style="background-image:url(images/buttonfirst.png);background-position:bottom;width:259px;height:41px" onclick="displayResult()"&gt;&lt;/div&gt; &lt;div id="button2" style="background-image:url(images/buttonsecond.png);width:259px;height:41px" onclick="displayResult1()"&gt;&lt;/div&gt; &lt;div id="button3" style="background-image:url(images/buttonthird.png);width:259px;height:41px" onclick="displayResult2()"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>So the buttons toggle different positions, and the script cycles through the positions at time intervals</p> <p>Now what I'm trying to achieve is that when the positions are being cycled through, if I click on one of the button, it jumps to the related position and stays that way for a while (say a few seconds) and then continue with the loop.</p> <p>Hope I've made my motive easy to understand.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload