swal 的簡單使用例子
swal
詢問彈窗
$(".comments .commentDel").on('click',function () {
swal({
title: "提示",
text: "確定要刪除該評論嗎?",
icon: "warning",
buttons: true,
}).then((y) => {
if (y) {
let id=$(this).data('id');
Ajax('/api/delComment','POST',{id:id},function (res) {
$("#comment-"+id).prev("hr").remove();
$("#comment-"+id).remove();
});
}
});
});
swal
普通彈窗
/**評論*/
$(".comments").on('click',".commentSubmit",function (event) {
let form=$(this).parents("form");
if(form[0].checkValidity()==false){
form.addClass("was-validated");
}else{
let data=form.serialize();
Ajax(comment_url,'post',data,function (res) {
swal(res.msg, '', "success").then(function () {
location.reload()
});
});
}
return false;
});
文章來源:劉俊濤的博客 歡迎關注公衆號、留言、評論,一起學習。
若有幫助到您,歡迎捐贈支持,您的支持是對我堅持最好的肯定(_)