jQuery & Javascript – Schedule a Function call by setTimeout()

In Javascript, you could schedule a function call using the setTimeout().

<html>
  <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
        setTimeout(delayedAlert, 3000);
      });
		
      function delayedAlert() {
        alert("Hello Eureka!");
      }
    </script>
  </head>
  <body>
    <h1>Eureka!</h1>
  </body>
</html>


 

The alert box will be shown in 3 seconds after the page is loaded.

Done =)

Next suggested post: Javascript – Passing Parameters for the Function in setTimeout()

One thought on “jQuery & Javascript – Schedule a Function call by setTimeout()”

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.