gpt4 book ai didi

javascript - 如何让javascript sweetalert2的确认框返回true

转载 作者:行者123 更新时间:2023-11-28 14:55:09 24 4
gpt4 key购买 nike

我想将我的警报框更改为 Sweet Alert2 ( https://sweetalert2.github.io/ )。单击确认警报窗口上的“确定”按钮后,似乎没有发生任何事情。我似乎不知道出了什么问题或如何解决问题。我的代码如下:

HTML:

<a href="functionalities/removeIncoming.php?incId=<?php echo $incID; ?>"> 
<button type="button" class="btn btn-default" id="delBtn" onclick="validateRemove(event);">
<span class="glyphicon glyphicon-book" aria-hidden="true"></span>
</button>
</a>

Javascript:

function validateRemove(e) {
e.preventDefault();
swal({
title: "Are you sure you want to archive this entry?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes',
cancelButtonText: "No"
}).then(function () {
swal(
'Archived',
'Your file has been Archived.',
'success'
)
})
}

最佳答案

onclick="confirm1();"

function confirm1()
{

swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',
buttonsStyling: false
}).then(function () {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
//success method
}, function (dismiss) {
// dismiss can be 'cancel', 'overlay',
// 'close', and 'timer'
if (dismiss === 'cancel') {
swal(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
}

关于javascript - 如何让javascript sweetalert2的确认框返回true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43168737/

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