I want to force a function to wait 1 second before she continues after to do that in javascript . For example:
function DoSomething(){
// wait 1 second
//continue w.e is this function does.
}
Thanks.
I want to force a function to wait 1 second before she continues after to do that in javascript . For example:
function DoSomething(){
// wait 1 second
//continue w.e is this function does.
}
Thanks.
If i understand you right , you need this:
setTimeout(DoSomething ,1000);
Edit , thanks to Teemu:
function DoSomething (){
setTimeout(ContinueDoSomething ,1000);
}
function ContinueDoSomething (){
// ...
}
And even one more way , may be most effective in some cases:
function DoSomething (){
setTimeout( function(){
// ...
},1000);
}