setTimeout()





js/script.js
  • function funString() {
  •  var str = 'Hello World!';
  •  document.getElementById('p').innerHTML = str;
  • }
  •  
  • function funMake() {
  •  setTimeout ('funString()', 2000);
  • }
  • function funString() {
  •  var str = 'Hello World!';
  •  document.getElementById('p').innerHTML = str;
  • }
  •  
  • function funMake() {
  •  setTimeout ('funString()', 2000);
  • }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <p id="p"></p>
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <p id="p"></p>
  •  <script>
  •   funMake();
  •  </script>
  • </body>
  • </html>