即使在JQuery中传递参数后,Sweetalert也没有更改按钮颜色

时间:2017-09-29 21:52:04

标签: jquery sweetalert

这就是我使用JQuery调用甜蜜警报的方式:

swal({
        buttonColor: '#000000',
        title: "Error!",
        text: "Please Enter Following Fields it Cannot be Left Blank\n ------------------------ \n"+fieldCheck,
        type: "error"
    });

但是,当使用ok按钮显示警报时,它仍然具有主要的蓝色,并且不会改变。

我也尝试添加课程,但我无法弄清楚如何申请课程。

1 个答案:

答案 0 :(得分:2)

如果您使用的是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>