settimeout javascript

Click the button to wait 3 seconds, then alert “Hello”.

settimeout function in javascript

<!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>
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *