JavaScript USES setTimeout to implement the delay pop up warning method

  • 2020-05-26 07:48:18
  • OfStack

This article illustrates how JavaScript USES setTimeout to implement a delay pop-up warning box. Share with you for your reference. The details are as follows:

After the following code is executed, clicking the button will delay for 3 seconds, and a warning box will pop up, which mainly demonstrates the use method of setTimeout


<!DOCTYPE html>
<html>
<body>
<p>
Click the button to wait 3 seconds, then alert "Hello".
</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction()
{
setTimeout(function(){alert("Hello")},3000);
}
</script>
</body>
</html>

I hope this article has been helpful to your javascript programming.


Related articles: