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

175
Views
How to use sweet alert on button

message like that

Swal.fire(

  'Good job!',

  'You clicked the button!',

  'success'

)

When I click my button then I want to show that message

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

function alertMsg(){
 Swal.fire(
  'Good job!',
  'You clicked the button!',
  'success'
)
}
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.3.3/dist/sweetalert2.all.min.js"></script>
<button onClick="alertMsg()">Button</button>

about 4 years ago · Juan Pablo Isaza Report

0

There are different ways to achieve this, I don't know if your button has an id or class you can attach an event for that, you should use the on click event. Learn more about events here.

This is a simple example:

<button onclick="showSwalAlert()">My Button</button>
<script>
 function showSwalAlert(){
    Swal.fire(
    'Good job!',
    'You clicked the button!',
    'success'
   )
  }
</script>
about 4 years ago · Juan Pablo Isaza 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!