我有这个jquery确认代码,我试图将其转换为甜蜜警报确认。
我目前的jquery:
$('#nav-logout').click(function(){
var res = confirm('Would you like to log out from the system?');
if(res) {
return true;
}
return false;
});
有人可以帮助我如何将此代码转换为基于上述代码的甜蜜警报确认。谢谢!
答案 0 :(得分:3)
这是设置
的简单代码示例
$("#nav-logout").click(function(e) {
e.preventDefault()
swal({
title : "",
text : "Would you like to log out from the system?",
type : "warning",
showCancelButton: true,
confirmButtonText: "Yes",
},
function(isConfirm){
if (isConfirm) {
//window.location="logut page url"; // if you need redirect page
alert("Press Yes");
} else {
alert("Cancelled");
}
})
});

<script src="http://tristanedwards.me/u/SweetAlert/lib/sweet-alert.js"></script>
<link href="http://tristanedwards.me/u/SweetAlert/lib/sweet-alert.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<a href="http://anything.com" title="r" class="nav-tools" id="nav-logout">Logout</a>
&#13;