Run function after 3 seconds Jquery / Javascript [duplicate]

-2

I have the following code, which creates two variables and call a function that displays an alert, but I want the function check_abertura () to execute after 3 seconds, how to do this?

var valor_min = 20;
var valor_max = 40;
verifica_abertura(valor_min, valor_max);

function verifica_abertura(valor_min, valor_max){
    alert(valor_min);
    alert(valor_max);
}
    
asked by anonymous 07.06.2018 / 14:41

1 answer

1

Circle with

setTimeout(function(){ /*código a ser executado no tempo informado*/ }, 3000);

parameter 3000 is the time in milliseconds

var valor_min = 20;
var valor_max = 40;
setTimeout(function(){
  verifica_abertura(valor_min, valor_max);
}, 3000);

function verifica_abertura(valor_min, valor_max){
    alert(valor_min);
    alert(valor_max);
}
    
08.06.2018 / 02:31