Example buttons notice in SweetAlert

Example 1: button waring

 

<!DOCTYPE html>

<html>

    <body>

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

        <p>Example Alert use button notice</p>

 

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

        <script>

            function run() {

               swal({

                  text: "Do you want delete it!",

                  icon: "warning",

                  buttons:true

                });

            }

        </script>

    </body>

</html>

 

Result:

 

 

Example 2: button success

 

<!DOCTYPE html>

<html>

    <body>

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

        <p>Example Alert use button notice</p>

 

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

        <script>

            function run() {

               swal({

                  text: "Deleted success!",

                  icon: "success",

                  button:"OK"

                });

            }

        </script>

    </body>

</html>

 

Result:

 

 

Example 3: Button fail

 

<!DOCTYPE html>

<html>

    <body>

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

        <p>Example Alert use button notice</p>

 

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

        <script>

            function run() {

               swal({

                  text: "Deleted fail!",

                  icon: "error",

                  button:"OK"

                });

            }

        </script>

    </body>

</html>

 

Result:

 

 

Example 4: Button info and timer

 

 

<!DOCTYPE html>

<html>

    <body>

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

        <p>Example Alert use button notice</p>

 

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

        <script>

            function run() {

               swal({

                  text: "User no exist!",

                  icon: "info",

                  timer: 1000,

                  button: false

                });

            }

        </script>

    </body>

</html>

 

Result: