Example use timer of SweetAlert

Closes the modal after a certain amount of time (specified in ms). Useful to combine with buttons:false.

Example: Use timer close modal


<!DOCTYPE html>



        <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

        <p>Example Alert use timer</p>


        <button onclick="run()">Run</button>



            function run() {

               swal("This modal will disappear soon!", {

                  buttons: false,

                  timer: 3000,










Modal will close after 3 seconds