Delay running a function for 3 seconds - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:delay

Description

Delay running a function for 3 seconds

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*from   www . j av  a 2  s  .  c o  m*/
$('#txt1').on('blur', function () {
    var $this = $(this);
    if ($this.val() === '') {
        setTimeout(function () {
            $this.val('4/11/2018');
        }, 3000);
    }
});
    });

      </script> 
 </head> 
 <body> 
  <input type="text" id="txt1">  
 </body>
</html>

Related Tutorials