📅  最后修改于: 2023-12-03 15:05:25.559000             🧑  作者: Mango
SweetAlert is a beautiful, responsive, customizable and versatile popup/alert dialog box library for JavaScript released by RealRashid. It can be used for a wide range of applications, from notifying users of successful or failed actions, to asking for confirmation before dangerous actions like deleting or overwriting data.
To use SweetAlert, simply download and include the script and CSS files in your project, and initialize it using JavaScript:
<script src="sweetalert.min.js"></script>
<link rel="stylesheet" href="sweetalert.css">
<script>
swal("Hello World!");
</script>
This will display a simple SweetAlert dialog box with the text "Hello World!".
swal({
title: "Are you sure?",
text: "You will not be able to recover this data!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal("Poof! Your data has been deleted!", {
icon: "success",
});
} else {
swal("Your data is safe!");
}
});
swal("What's your name?", {
content: "input",
})
.then((value) => {
swal(`Hello, ${value}!`);
});
swal("Good job!", "You clicked the button!", "success");
swal("Oops...", "Something went wrong!", "error");
SweetAlert by RealRashid is a powerful and elegant popup/alert dialog box library that is perfect for all web developers. It is customizable, responsive, and easy to use, making it a valuable tool for any project. Its pre-built dialogs make it easy to prompt users for input, confirm actions, and display success or error messages. With SweetAlert, your web applications will look great and function even better.