我有一个表单按钮如下:
<input type="button" value="Leave Room" id="disconnectLink" onclick="javascript:getConfirmation();" style="display: none" />
和getConfirmation()函数如下:
function getConfirmation(){
var retVal = confirm("Are you sure that you want to leave room?");
if( retVal == true ){
disconnect();
return true;
}
工作正常并正确显示警报。我需要添加javascript sweetalert显示: https://www.ludu.co/lesson/how-to-use-sweetalert
我尝试了以下内容:
function getConfirmation(){
swal({
title: "Are you sure?",
text: "Are you sure that you want to leave room?",
type: "warning",
showCancelButton: true,
closeOnConfirm: false,
confirmButtonText: "Yes, leave room!",
confirmButtonColor: "#ec6c62"
}, function() {
disconnect();
return true;
else{
return false;
}
}
})
但不幸的是,它没有工作,点击“离开房间”按钮时没有任何反应。
以上代码出了什么问题??