gpt4 book ai didi

javascript - 显示甜蜜警报对话框时出错

转载 作者:行者123 更新时间:2023-12-01 05:21:06 25 4
gpt4 key购买 nike

我正在尝试使用 Sweet Alert 发出警报图书馆。我尝试集成代码来发出删除项目的确认警报,但是当我单击删除项目的按钮时,这些代码不起作用。不显示该对话框。

集成 Sweet Alert之前的代码:

$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
if (confirm('Sure to Delete ID no = ' + del_id)) {
$.post('delete.php', { 'del_id': del_id }, function(data) {
parent.fadeOut('slow');
});
}
return false;
});

集成 Sweet Alert之后的代码:

    $(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
});

swal({
title: "Are you sure you want to delete?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
closeOnConfirm: false
},
function() {
$.post('delete.php', { 'del_id': del_id }, function(data) {
parent.fadeOut('slow');
});
});
return false;

});

最佳答案

我认为您的代码中存在语法错误。试试这个,看看它是否有效[我还没有测试我这边的代码]。如果不起作用,请告诉我

$(".delete-link").click(function() {
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");

swal({
title: "Are you sure you want to delete?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: true,
closeOnCancel: true
}, function(isConfirm) {
$.post('delete.php', {'del_id':del_id}, function(data) {
parent.fadeOut('slow');
});
});
return false;
});

关于javascript - 显示甜蜜警报对话框时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43709713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com