Javascript 自定义警报甜警报
我用JavaScript制作了此警报。这是一个简单的警报,显示一个框:确定要删除ID号=。。并显示“确定”或“取消”按钮 我想将此警报转换为甜蜜警报。我怎么能做到 代码:Javascript 自定义警报甜警报,javascript,Javascript,我用JavaScript制作了此警报。这是一个简单的警报,显示一个框:确定要删除ID号=。。并显示“确定”或“取消”按钮 我想将此警报转换为甜蜜警报。我怎么能做到 代码: $(document).ready(function(){ $(".delete-link").click(function() { var id = $(this).attr("id"); var del_id = id; var parent = $(this
$(document).ready(function(){
$(".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;
});
});
尝试以下方法:
$(document).ready(function(){
$(".delete-link").click(function(e))
{
e.preventDefault();
var id = $(this).attr("id");
var del_id = id;
var parent = $(this).parent("td").parent("tr");
swal({
title: "Are you sure?",
text: "Sure to Delete ID no = " + del_id,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
},
function(){
$.post('delete.php', {'del_id':del_id}, function(data)
{
parent.fadeOut('slow');
});
});
});
});
参考:!你至少要表现出一些努力。。。
swal({
title: "Are you sure?",
text: "Text here.",
icon: "warning",
buttons: [
"No, don't do that!",
'Yes, do that'
],
dangerMode: true,
}).then(function (isConfirm) {
if (isConfirm) {
swal({
title: 'Done',
text: 'Your task has been done!',
icon: 'success'
})
} else {
swal("Not done", "your task has not been done", "error");
}