sweetalert2 confirm 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: sweetalert2

$ npm install sweetalert2

Example 3: sweetalert2

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

Example 4: jquery sweet popup

$.sweetModal.prompt('Can I haz cheezeburger?', 'Can I?', 'Nope', function(val) {
	$.sweetModal('You typed: ' + val);
});

Example 5: sweetalert confirm box

swal({  title: "Are you sure?",  text: "Once deleted, you will not be able to recover this imaginary file!",  icon: "warning",  buttons: true,  dangerMode: true,}).then((willDelete) => {  if (willDelete) {    swal("Poof! Your imaginary file has been deleted!", {      icon: "success",    });  } else {    swal("Your imaginary file is safe!");  }});

Example 6: sweetalert2

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>