Change color in an async function - Javascript Function

Javascript examples for Function:Function Async

Description

Change color in an async function

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//  www .j a v a  2 s . c om
var startChangingColor = setInterval(function() {changeColor()}, 1000);

function changeColor() {
  var chooseColor = 'red';
  document.body.style.backgroundColor = chooseColor;
  if (chooseColor === "") {
        clearInterval(startChangingColor);
  }
}
    }

      </script> 
   </head> 
   <body>    
   </body>
</html>

Related Tutorials