Sweetalert not changing the button color even after passing the parameter in JQuery

Viewed 4967

This is how I am calling the sweet alert using JQuery:

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

But still, when the alert is being displayed with the ok button it has a primarily blue color which doesn't change.

also i tried to add a class but i am not able to figure out that how can i apply a class.

1 Answers

If you are using SweetAlert2 you need to change:

buttonColor: '#000000',

to:

confirmButtonColor: '#000000',

A different approach is to style directly the button:

.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>

Related