Is there any of when a user enters a page, does the JavaScript wait 20 seconds and after waiting for those 20 seconds to show a submit in real time?
To execute a function after a certain time, use the function .setTimeout(callback, delay)
.
It is important to note that the delay parameter is represented in milliseconds, as described below:
delay is the number of milliseconds (thousandths of a second) that the call function should be delayed by. If omitted, it defaults to 0. The current delay may be longer; see Notes below.
Suppose you have a function named minhaFuncao
, and want to run it after 20 seconds. In this case you would use the following syntax:
setTimeout(minhaFuncao, 20000);
Example
function showSubmit() {
document.getElementById('submit-btn').style.display = 'block';
}
setTimeout(showSubmit, 2000);
#submit-btn {
display: none;
}
<input type="submit" id="submit-btn">