Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.6K
Views
How do I change css hover property of sweet Alert button?

I want to change the :hover property of the sweet alert confirm button. I wrote the following code:

sweetAlert({
            title: "<span style='color: #134563'>[My title]",
            text: "<span style='font-size: 20px'>[My Message.....]",
            imageUrl: "images/email-icon.png",
            allowOutsideClick: false,
            confirmButtonColor: "#134563",
            customClass: ".sweet-alert button:hover{ background:'#2b5c79'; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; }",
            html: true
        });

But I don't get the :hover property even with the class customization. How can I solve that?

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Update

You need to define the customClass as this: customClass: ".sweet-alert button". Now you can define the styles in your stylesheet (css) as .sweet-alert button:hover{ background:'#2b5c79'; -webkit-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; }. I know the snippet does not work, it is for illustrative purposes only. You can find the documentation here or docu sweetalert2 (examples are given).

sweetAlert({
            title: "<span style='color: #134563'>[My title]",
            text: "<span style='font-size: 20px'>[My Message.....]",
            imageUrl: "images/email-icon.png",
            allowOutsideClick: false,
            confirmButtonColor: "#134563",
            customClass: ".sweet-alert button",
            html: true
        });
.sweet-alert button:hover { 
  background:'#2b5c79'; 
  -webkit-transition: all 0.3s ease-in-out; 
  transition: all 0.3s ease-in-out; 
}


Old Answer

You can try this. Add These Events to your button, you simultate the hover Event.

$(".myclass").mouseover(function() {
    $(this).css("background-color","red");
}).mouseout(function() {
    $(this).css("background-color","transparent");
});
.myclass {
  height: 50px;
  width: 100%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="myclass"></div>

about 4 years ago · Santiago Trujillo Report

0

You can use jquery to target the button directly:

$(".swal2-confirm.swal2-styled").on('mouseenter', function() {$(this).css('background', 'green')})

Result:

enter image description here

To set the color when leaving:

$(".swal2-confirm.swal2-styled").on('mouseleave', function() {$(this).css('background', 'blue')})
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!