sweet alert 2 do action on confirm
Swal.fire({ title: 'Do you want to save the changes?', showDenyButton: true, showCancelButton: true, confirmButtonText: `Save`, denyButtonText: `Don't save`, }).then((result) => { /* Read more about isConfirmed, isDenied below */ if (result.isConfirmed) { Swal.fire('Saved!', '', 'success') } else if (result.isDenied) { Swal.fire('Changes are not saved', '', 'info') } });
Source: sweetalert2.github.io
Sweetalert
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> <script>swal("My title", "My description", "success");</script>
switch alert
swal({ title: "Good job!", text: "You clicked the button!", icon: "success", button: "Aww yiss!" });
Source: sweetalert.js.org
sweet alert example
swal({ title: "Good job!", text: "You clicked the button!", icon: "success", button: "Aww yiss!", });
Source: sweetalert.js.org
sweetalert example
//import sweetalert <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> //Alert <script>swal("My title", "My description", "success");</script>
sweetalert js full code
<script> // when window loades this alert pop ups swal({ text: "Hello world!", } ); </script>