آلارت پایه
دلار("#kt_sweetalert_demo_1").click(function(e) {
Swal.fire("آفرین!");
});
عنوان و متن آلارت
دلار("#kt_sweetalert_demo_2").click(function(e) {
Swal.fire("Here's the title!", "...and here's the text!");
});
warning, error, success, info و question
دلار("#kt_sweetalert_demo_3_1").click(function(e) {
Swal.fire("آفرین!", "شما clicked the button!", "warning");
});
دلار("#kt_sweetalert_demo_3_2").click(function(e) {
Swal.fire("آفرین!", "شما clicked the button!", "error");
});
دلار("#kt_sweetalert_demo_3_3").click(function(e) {
Swal.fire("آفرین!", "شما clicked the button!", "success");
});
دلار("#kt_sweetalert_demo_3_4").click(function(e) {
Swal.fire("آفرین!", "شما clicked the button!", "info");
});
دلار("#kt_sweetalert_demo_3_5").click(function(e) {
Swal.fire("آفرین!", "شما clicked the button!", "question");
});
تغییر متن و کلاس دکمه تایید
دلار("#kt_sweetalert_demo_4").click(function (e) {
Swal.fire({
title: "آفرین!",
text: "شما clicked the button!",
icon: "success",
buttonsStyling: false,
confirmدکمهمتن: "Confirm me!",
customکلاس: {
confirmدکمه: "btn btn-primary"
}
});
});
دکمه با آیکون سفارشی
دلار("#kt_sweetalert_demo_5").click(function (e) {
Swal.fire({
title: "آفرین!",
text: "شما clicked the button!",
icon: "success",
buttonsStyling: false,
confirmدکمهمتن: "<i class='la la-headphones'></i> I am game!",
showلغودکمه: true,
cancelدکمهمتن: "<i class='la la-thumbs-down'></i> No, thanks",
customکلاس: {
confirmدکمه: "btn btn-danger",
cancelدکمه: "btn btn-default"
}
});
});
نمایش یک پیام با تایمر بسته شدن و تعیین موقعیت دیالوگ باکس
دلار("#kt_sweetalert_demo_6").click(function(e) {
Swal.fire({
position: "top-right",
icon: "success",
title: "شما work has been saved",
showConfirmButton: false,
timer: 1500
});
});
سفارشی animate.rtl.css انیمیشن
دلار('#kt_sweetalert_demo_7').click(function (e) {
Swal.fire({
title: 'jQuery جی اس example',
showکلاس: {
popup: 'animate__animated animate__fadeInDown'
},
hideکلاس: {
popup: 'animate__animated animate__fadeOutUp'
}
});
});
یک پیام هشدار با یک دکمه که میتواند یک فانکشن را اجرا کند
دلار("#kt_sweetalert_demo_8").click(function(e) {
Swal.fire({
title: "Are you sure?",
text: "شما won"t be able to revert this!",
icon: "warning",
showلغودکمه: true,
confirmدکمهمتن: "Yes, delete it!"
}).then(function(result) {
if (result.value) {
Swal.fire(
"حذفd!",
"شما file has been deleted.",
"success"
)
}
});
});
دو دکمه که در صورت فشردن هر دکمه می توان یک فانکشن را اجرا کرد
دلار("#kt_sweetalert_demo_9").click(function(e) {
Swal.fire({
title: "Are you sure?",
text: "شما won"t be able to revert this!",
icon: "warning",
showلغودکمه: true,
confirmدکمهمتن: "Yes, delete it!",
cancelدکمهمتن: "No, cancel!",
reverseدکمه ها: true
}).then(function(result) {
if (result.value) {
Swal.fire(
"حذفd!",
"شما file has been deleted.",
"success"
)
// result.dismiss can be "cancel", "overlay",
// "close", and "timer"
} else if (result.dismiss === "cancel") {
Swal.fire(
"لغوled",
"شما imaginary file is safe :)",
"error"
)
}
});
});
یک پیام سفارشی یا یک عکس
دلار("#kt_sweetalert_demo_10").click(function(e) {
Swal.fire({
title: "Sweet!",
text: "مودال with a custom image.",
imageUrl: "https://unsplash.it/400/200",
imageWidth: 400,
imageارتفاع: 200,
imageAlt: "سفارشی image",
animation: false
});
});
یک پیام با تایمر بسته شدن
دلار("#kt_sweetalert_demo_11").click(function(e) {
Swal.fire({
title: "Auto close alert!",
text: "I will close in 5 seconds.",
timer: 5000,
onOpen: function() {
Swal.showLoading()
}
}).then(function(result) {
if (result.dismiss === "timer") {
console.log("I was closed by the timer")
}
})
});