<button onclick="setTimeout(myFunction, 3000)">Try it</button> <script> function myFunction() { alert('Hello'); } </script>