Search code examples
javascriptdomsweetalertsweetalert2

Removing SweetAlert2 from DOM after dialog closes


swal({
  title: "Etsi ohjelmaa!",
  text: "Kirjoita ohjelman nimi:",
  type: "input",
  showCancelButton: true,
  closeOnConfirm: true,
  animation: "slide-from-top",
  inputPlaceholder: nimi
}

I tried onClose: $("sweet-alert").removeClass() but it doesn't work. Also I should remove class "sweet-overlay".

So how to remove Sweet-alert from DOM after dialog closes?

https://sweetalert2.github.io/


Solution

  • SweetAlert2 removes itself after closing, proof:

    Make sure you're using the latest version.