即使在 JQuery 中传递参数后,Sweetalert 也不会更改按钮颜色
Sweetalert not changing the button color even after passing the parameter in JQuery
这就是我使用 JQuery 调用甜蜜警报的方式:
swal({
buttonColor: '#000000',
title: "Error!",
text: "Please Enter Following Fields it Cannot be Left Blank\n ------------------------ \n"+fieldCheck,
type: "error"
});
但是,当使用确定按钮显示警报时,它的主要颜色是蓝色,并且不会改变。
我也尝试添加 class,但我不知道如何应用 class。
如果您正在使用 SweetAlert2,您需要更改:
buttonColor: '#000000',
至:
confirmButtonColor: '#000000',
另一种方法是直接设置按钮的样式:
.swal2-confirm {
font-family: "Times New Roman", Times, serif !important;
font-size: 30px !important;
background-color: #000000 !important;
border-left-color: #000000 !important;
border-right-color: #000000 !important;
}
var fieldCheck = '';
swal({
confirmButtonColor: '#000000',
title: "Error!",
text: "Please Enter Following Fields it Cannot be Left Blank\n ------------------------ \n"+fieldCheck,
type: "error"
});
.swal2-confirm {
font-family: "Times New Roman", Times, serif !important;
font-size: 30px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.9.1/sweetalert2.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.9.1/sweetalert2.min.js"></script>
这就是我使用 JQuery 调用甜蜜警报的方式:
swal({
buttonColor: '#000000',
title: "Error!",
text: "Please Enter Following Fields it Cannot be Left Blank\n ------------------------ \n"+fieldCheck,
type: "error"
});
但是,当使用确定按钮显示警报时,它的主要颜色是蓝色,并且不会改变。
我也尝试添加 class,但我不知道如何应用 class。
如果您正在使用 SweetAlert2,您需要更改:
buttonColor: '#000000',
至:
confirmButtonColor: '#000000',
另一种方法是直接设置按钮的样式:
.swal2-confirm {
font-family: "Times New Roman", Times, serif !important;
font-size: 30px !important;
background-color: #000000 !important;
border-left-color: #000000 !important;
border-right-color: #000000 !important;
}
var fieldCheck = '';
swal({
confirmButtonColor: '#000000',
title: "Error!",
text: "Please Enter Following Fields it Cannot be Left Blank\n ------------------------ \n"+fieldCheck,
type: "error"
});
.swal2-confirm {
font-family: "Times New Roman", Times, serif !important;
font-size: 30px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.9.1/sweetalert2.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.9.1/sweetalert2.min.js"></script>