sweet alert jquery code example

Example 1: 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')  
 	}
});

Example 2: Sweetalert

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>swal("My title", "My description", "success");</script>

Example 3: switch alert

swal({
	title: "Good job!",
	text: "You clicked the button!",
	icon: "success",
	button: "Aww yiss!"
});

Example 4: sweetalert

<script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>

Example 5: how to use sweetalert

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

Example 6: sweet alert

swal("Good job!", "You clicked the button!", "success");