Get started with sweetalert CDN

MIT licensed

SweetAlert is a popular library for displaying customizable and visually appealing alert boxes.

Tags:
  • alert
  • modal
  • sweetalert
  • popup
  • dialog
  • ui

Stable version

Copied!

How to start using sweetalert CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with sweetalert CDN - cdnhub.io</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.css">
</head>
<body>
  <button id="alert-button">Show Alert</button>

  <script src="https://cdn.cdnhub.io/sweetalert/2.1.2/sweetalert.min.js"></script>
  <script>
    document.getElementById('alert-button').addEventListener('click', function() {
      Swal.fire({
        title: 'Are you sure?',
        text: 'This action cannot be undone!',
        icon: 'warning',
        showCancelButton: true,
        confirmButtonText: 'Yes, delete it!',
        cancelButtonText: 'No, cancel!',
        reverseButtons: true
      }).then((result) => {
        if (result.isConfirmed) {
          Swal.fire('Deleted!', 'Your file has been deleted.', 'success')
        }
      })
    })
  </script>
</body>
</html>
Copied!

All versions