Run function after 3 seconds Jquery/Javascript

Asked

Viewed 3,956 times

-1

I have the following code, which creates two variables and I call a function that displays an Alert, but I want the function verifi_aperture() to be executed 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);
}

1 answer

4


Circumde with

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

the 3000 parameter 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);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.