Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay the execution of jQuery script for specific time . .

Tags:

jquery

I want to delay the execution of jQuery script for specific time.

For example, I have a user define function ABC() and i want to call this function after a few seconds.

my example code is below

<script type="text/javascript">
  var i = $('#test').val();
  //here i want to delay the script for a few second 
  var value =  ABC();    
</script>

How can I achieve this?

like image 420
chhameed Avatar asked Dec 28 '22 18:12

chhameed


1 Answers

Use setTimeout:

 var value = null; //set a default value
 setTimeout( function(){
      value =  ABC();
 }, 3000); //3 seconds
like image 138
Naftali Avatar answered Feb 01 '23 06:02

Naftali