Answer the question
In order to leave comments, you need to log in
How to do this in javascript?
When the form is submitted (in a Bootstrap modal window), a countdown counter should appear (let's say 30 seconds) and after that a certain caption should appear. Can you please tell me how this can be done? (at least approximately, I just don’t understand much in js)
Answer the question
In order to leave comments, you need to log in
Use a function setInterval
: https://jsfiddle.net/j29pf67j/1/
var counter = document.getElementById("counter")
var hiddenText = document.getElementById("hidden-text")
var run = function(seconds) {
var interval = setInterval(function(){
if (seconds > 0) {
counter.textContent = seconds--;
}
else
{
hiddenText.style.display = "block";
counter.style.display = "none";
clearInterval(interval);
}
}, 1000)
}
function showMessage(){
alert('Done');
}
setTimeout(showMessage, 30000);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question