Javascript examples for Function:Function Async
Change color in an async function
<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>