javascript - display buttons for few seconds and then reset screen -
i have piece of code makes counter work 2 minutes. after 2 min on alert box appears informing time completion.
what trying when alert box appears , user clicks ok , returns screen want make 2 buttons disappear , 1 button should stay. till here have been able part(also indicated through comment b/w code) should stay 20 seconds , after screen should reset automatically.
the code using is
var ticker = function() { counter--; var t = (counter / 60) | 0; // round off digits.eq(0).text(t); t = ((counter % 60) / 10) | 0; digits.eq(2).text(t); t = (counter % 60) % 10; digits.eq(3).text(t); if (!counter) { clearinterval(timer); alert('sorry, time out.'); /***3 lines given below should stay 20 sec , after screen should reset***/ $("#count").hide(); $("#walkaway").show(); $("#submitamt").hide(); } };
you should use settimeout
instead of setinterval
. work?
$(function () { settimeout(function () { alert("alert came after 2 mins."); $(".after-2mins").show(); settimeout(function () { location.href = location.href; }, 2000); }, 5000); });
* {font-family: 'segoe ui'; margin: 0; padding: 0; list-style: none;} .hidden {display: none;}
<script src="https://code.jquery.com/jquery-1.9.1.js"></script> <p>wait 2 mins. 5 seconds in demo.</p> <div class="after-2mins hidden"> <p>2 mins over. displaying 2 buttons. after 20 seconds, reload. 2 seconds in demo.</p> <input type="button" value="button1" /> <input type="button" value="button2" /> </div>
Comments
Post a Comment